inherit
242907
0
Jun 22, 2024 8:16:54 GMT -8
Sammiie
155
March 2017
sammiie
|
Post by Sammiie on Jul 11, 2020 15:07:08 GMT -8
What is the correct way to do this? I tried looking it up, but honestly this just confuses me and to me it looks correct, but it's not actually working - so I must be doing something wrong.
<div class="thread_icon"> {if $[thread.is_locked]}<i class="fa fa-lock" aria-hidden="true"></i> {elseif $[thread.is_announcement]}<i class="fa fa-exclamation-triangle" aria-hidden="true"></i> {elseif $[thread.is_sticky]<i class="fa fa-star" aria-hidden="true"></i>{else} <i class="fa fa-star-o" aria-hidden="true"></i>{/if} </div>
The line in question is:
{elseif $[thread.is_sticky]<i class="fa fa-star" aria-hidden="true"></i> I want to add a condition to make stickied threads have a different icon. I thought just duplicating the line above it and filling in the right things would work, but apparently not.
Any guidance would help! Thanks <3
|
|
inherit
252032
0
Apr 26, 2024 23:51:41 GMT -8
Retread
Tribbial Pursuit.
5,017
January 2018
retread
|
Post by Retread on Jul 11, 2020 16:44:16 GMT -8
The line in question is: {elseif $[thread.is_sticky]<i class="fa fa-star" aria-hidden="true"></i> Hi SammiieThat line is broken. Your conditional is missing the closing brace } after the template variable. It should look like this: {elseif $[thread.is_sticky]}<i class="fa fa-star" aria-hidden="true"></i> Worth noting, announcements, stuck threads and regular threads can all be locked (or not). The way you've sequenced your conditionals, if a thread is locked, it won't matter whether it is a regular thread, announcement or sticky. You will get the first result and all other conditionals will be ignored.
|
|
Kami
Forum Cat
Posts: 40,201
Mini-Profile Theme: Kami's Mini-Profile
#f35f71
156500
0
Offline
Jul 24, 2021 11:48:29 GMT -8
Kami
40,201
July 2010
kamiyakaoru
Kami's Mini-Profile
|
Post by Kami on Jul 11, 2020 16:55:16 GMT -8
I wouldn't use "elseif" for this because threads can exist in multiple states at a time (eg: a thread can be both a sticky and an announcement, depending on which board you're viewing in). EDIT oops retread said that mb friend.
It would be better to use combined statements if you want to differenciate:
{if [thread is locked stuff here]}{/if} {if $[thread.is_announcement] && !$[thread.is_sticky}<i class="fa fa-exclamation-triangle" aria-hidden="true"></i> {elseif $[thread.is_sticky] && !$[thread.is_announcement]<i class="fa fa-star" aria-hidden="true"></i> {else} <i class="fa fa-star-o" aria-hidden="true"></i> {/if}
I haven't tested this -- it should work though, let me know if it doesn't.
For clarity, the above code specifies: - if a thread is locked, display this icon. (i left this as a stand alone statement since you should 100% differentiate between a locked & unlocked thread regardless of sticky/announcement status) - if a thread is an announcement and NOT stickied, display this icon - if a thread is a sticky and NOT an announcement, display this icon - if neither of these conditions are filled, display this icon
NOTE: If you have a thread that is both stickied and an announcement, the "if neither" icon will display. To make this cohesive, you'll need to provide an icon for when both statements are true, or alternatively use both images if both statements are true.
|
|
inherit
242907
0
Jun 22, 2024 8:16:54 GMT -8
Sammiie
155
March 2017
sammiie
|
Post by Sammiie on Jul 11, 2020 20:16:37 GMT -8
Retread thank you! Them teensy, tinsy mistakes, eh? xD Yes, that was the plan! Kami I tried the code you offered, and it doesn't show the stickied or locked icons differently; everything just has the default icon.
|
|
Kami
Forum Cat
Posts: 40,201
Mini-Profile Theme: Kami's Mini-Profile
#f35f71
156500
0
Offline
Jul 24, 2021 11:48:29 GMT -8
Kami
40,201
July 2010
kamiyakaoru
Kami's Mini-Profile
|
Post by Kami on Jul 11, 2020 21:54:16 GMT -8
OK, i may have gotten the syntax wrong, give me a few.
|
|
Kami
Forum Cat
Posts: 40,201
Mini-Profile Theme: Kami's Mini-Profile
#f35f71
156500
0
Offline
Jul 24, 2021 11:48:29 GMT -8
Kami
40,201
July 2010
kamiyakaoru
Kami's Mini-Profile
|
Post by Kami on Jul 11, 2020 22:06:15 GMT -8
Retread thank you! Them teensy, tinsy mistakes, eh? xD Yes, that was the plan! Kami I tried the code you offered, and it doesn't show the stickied or locked icons differently; everything just has the default icon. This works fine for me actually (announcement threads are Y, stickied threads are X, and threads that are neither or both are BOOP): kamitest5.proboards.com/board/1/general-boardCan you copy/paste exactly what you have? and for clarity, it shouldn't show the locked icons differently. i don't know if you misspoke there, or if you're under the wrong impression, but what the code does is: - shows locked icons [ note: on my test site it just SAYS "LOCKED"] if the thread is locked (regardless of sticky/announcement status) - shows one icon if the thread is an announcement - shows the other icon if the thread is a sticky - shows a THIRD icon if the thread fails to meet these requirements (either is neither, or is both). Attachments:
|
|
inherit
252032
0
Apr 26, 2024 23:51:41 GMT -8
Retread
Tribbial Pursuit.
5,017
January 2018
retread
|
Post by Retread on Jul 12, 2020 6:10:54 GMT -8
Them teensy, tinsy mistakes, eh? xD Yeah. Been there, done that. Depending on what you want to accomplish, there are different ways to slice this. You could make simple {if} loops and close each one. This would give you additive results if more than one conditional is true. Or you could use {elseif} within the {if} loop and be very specific about defining combinations of conditions, sequencing them from most restrictive to least restrictive. This would give you unique results based on which combination of conditions are met. For instance: <div class="thread_icon"> {if $[thread.is_announcement] && $[thread.is_sticky] && $[thread.is_locked]} *action if all are true here*
{elseif $[thread.is_announcement] && $[thread.is_sticky]} *action if announcement is sticky here*
{elseif $[thread.is_announcement] && $[thread.is_locked]} *action if announcement is locked here*
{elseif $[thread.is_sticky] && $[thread.is_locked]} *action if sticky is locked here*
{elseif $[thread.is_announcement]} *action if announcement here*
{elseif $[thread.is_sticky]} *action if sticky here*
{elseif $[thread.is_locked]} *action if thread is locked here*
{else} *action if just plain thread here*
{/if} </div> If at any point in this sequence of decisions, the combination of conditions is met, the action is taken and we leave the {if} loop. If none of the combination of conditions is ever met, we find ourselves at the {else}. That action is performed and we then leave the {if} loop. Does that make sense? Or did I explain it poorly?
|
|
Kami
Forum Cat
Posts: 40,201
Mini-Profile Theme: Kami's Mini-Profile
#f35f71
156500
0
Offline
Jul 24, 2021 11:48:29 GMT -8
Kami
40,201
July 2010
kamiyakaoru
Kami's Mini-Profile
|
Post by Kami on Jul 12, 2020 7:06:50 GMT -8
Retread seems to have a handle on this so i'm bowing out. Good luck with your theme!
|
|