inherit
133146
0
Nov 16, 2024 15:51:08 GMT -8
Alanna π₯π€
3,564
November 2008
alannab
|
Post by Alanna π₯π€ on Dec 29, 2017 20:29:54 GMT -8
primalminds.proboards.com/Trying to get different board styles for different categories and the IF statement is NOT working how I want it to... this is what I got but it's only reading the first line, so only category 4 is working correctly, the rest are just being dumb: {foreach $[board]} {if $[board.category_id] == "4" && if $[board.category_id] == "5" && if $[board.category_id] == "6" && if $[board.category_id] == "7" && if $[board.category_id] == "8"} <!-- ROLE PLAY BOARDS --> {else} <!-- NORMAL BOARDS --> {/if} {/foreach}
|
|
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 Dec 29, 2017 20:52:42 GMT -8
primalminds.proboards.com/Trying to get different board styles for different categories and the IF statement is NOT working how I want it to... this is what I got but it's only reading the first line, so only category 4 is working correctly, the rest are just being dumb: {foreach $[board]} {if $[board.category_id] == "4" && if $[board.category_id] == "5" && if $[board.category_id] == "6" && if $[board.category_id] == "7" && if $[board.category_id] == "8"} <!-- ROLE PLAY BOARDS --> {else} <!-- NORMAL BOARDS --> {/if} {/foreach} && means all conditions have to be filled simultaneously. you cannot have a board have the ID of 4, 5, 6, 7, and 8 at the same time so the check is failing. You would need the inclusive or (||) instead. Alternatively use category IDs rather than board IDs depending on what youβre trying to accomplish.
|
|
inherit
133146
0
Nov 16, 2024 15:51:08 GMT -8
Alanna π₯π€
3,564
November 2008
alannab
|
Post by Alanna π₯π€ on Dec 30, 2017 10:06:30 GMT -8
primalminds.proboards.com/Trying to get different board styles for different categories and the IF statement is NOT working how I want it to... this is what I got but it's only reading the first line, so only category 4 is working correctly, the rest are just being dumb: {foreach $[board]} {if $[board.category_id] == "4" && if $[board.category_id] == "5" && if $[board.category_id] == "6" && if $[board.category_id] == "7" && if $[board.category_id] == "8"} <!-- ROLE PLAY BOARDS --> {else} <!-- NORMAL BOARDS --> {/if} {/foreach} && means all conditions have to be filled simultaneously. you cannot have a board have the ID of 4, 5, 6, 7, and 8 at the same time so the check is failing. You would need the inclusive or (||) instead. Alternatively use category IDs rather than board IDs depending on what youβre trying to accomplish. I've also tried that and it didn't work. XD
|
|
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 Dec 30, 2017 10:22:04 GMT -8
&& means all conditions have to be filled simultaneously. you cannot have a board have the ID of 4, 5, 6, 7, and 8 at the same time so the check is failing. You would need the inclusive or (||) instead. Alternatively use category IDs rather than board IDs depending on what youβre trying to accomplish. I've also tried that and it didn't work. XD it would help to see the whole template; even if its only one thing being affected, the culprit might not be what you think.
|
|
inherit
96289
0
May 17, 2020 9:37:00 GMT -8
elli
1,822
January 2007
ebbymac
|
Post by elli on Dec 31, 2017 13:01:10 GMT -8
I don't think you should need to repeat "if" in your statement. What about:
{if $[board.category_id] == "4" || $[board.category_id] == "5" || $[board.category_id] == "6" || $[board.category_id] == "7" || $[board.category_id] == "8"}
This worked for me to change the styles for the boards in those categories. You also don't need the category ID numbers in quotes, making it a string, but it seems to work both ways.
|
|
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 Dec 31, 2017 13:08:24 GMT -8
elli i completely missed that lmao, thanks!
|
|
inherit
133146
0
Nov 16, 2024 15:51:08 GMT -8
Alanna π₯π€
3,564
November 2008
alannab
|
Post by Alanna π₯π€ on Jan 1, 2018 14:28:37 GMT -8
I don't think you should need to repeat "if" in your statement. What about: {if $[board.category_id] == "4" || $[board.category_id] == "5" || $[board.category_id] == "6" || $[board.category_id] == "7" || $[board.category_id] == "8"} This worked for me to change the styles for the boards in those categories. You also don't need the category ID numbers in quotes, making it a string, but it seems to work both ways. Thank you! ??
|
|