inherit
220772
0
Mar 24, 2023 21:43:23 GMT -8
Tiffy-Bean
I support plugin and theme makers rights to create themes and plugins that are paid for.
1,052
April 2015
tiffythecodingwhiz
|
Post by Tiffy-Bean on Nov 28, 2016 1:58:37 GMT -8
Is there a way that you can string if/else to be multiple IDs like:
{if $[user.id] == "1" } {elseif $[user.id] == "2"; "3"; "4"} {/if}
I want the same instance for all of 2, 3, and 4 but not for 1..but I can't have it be universal either cause I want it to not be there at all on some..and if I list them out with each elseif seperately, I get too many foreach loops. Is it possible to list them together in the multiple tag?
|
|
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 Nov 28, 2016 2:47:25 GMT -8
Yes. The syntax should be:
{if $[user.id] == "1" } content for id 1 {elseif $[user.id] == "2" || $[user.id] == "3"} content for id 2 and 3 {/if}
And repeat || $[user.id] == "x" as necessary; I'm not 100% sure you need the quotes around the ID number as I'm not entirely familiar with which specifications need quotes -- board IDs do not for instance -- so if it doesn't work with quotes try without.
|
|
inherit
220772
0
Mar 24, 2023 21:43:23 GMT -8
Tiffy-Bean
I support plugin and theme makers rights to create themes and plugins that are paid for.
1,052
April 2015
tiffythecodingwhiz
|
Post by Tiffy-Bean on Nov 28, 2016 23:48:39 GMT -8
Oh thank you!!
|
|
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 Nov 29, 2016 3:15:53 GMT -8
|
|
inherit
223470
0
Feb 27, 2019 17:05:53 GMT -8
₪» ⅀ ƪ Ƒ «₪
Original registration date: 2007. DeviantART: http://deviantart.com/ruanly. Discord: Ruanly#7946.
1,281
July 2015
fajita
|
Post by ₪» ⅀ ƪ Ƒ «₪ on Nov 30, 2016 18:50:34 GMT -8
Tiffy-Bean just letting you know you can also use && for "and" just as || is "or" if you ever need. =) There's also a way to combine ranges of numbers for less variables if you'd like. If you're interested, here's some info... Warning: it's gonna make your layout template think it's broken. It will basically go red and it will cause whatever comes after it to also be red (I think whatever code is directly after it turns red and then it goes back to normal). It's okay. It's not actually broken and I got this coding from PB admins themselves, the layout templates just like to throw hissy fits about it. I've used them for years and have never once had issue besides the red in the layout templates themselves. Onto the code, I'll show you it hands-on. Here is an example of using ranges instead of naming every single group ID: {if ($[user.group.id] >= 1 && $[user.group.id] <= 4) || ($[user.group.id] >= 26 && $[user.group.id] <= 29)} So this is saying, in roughly translated code-to-english: "if the user group ID is 1,2,3, or 4 OR if the user group ID is 26, 27, 28, or 29, then...." If you're like me and have to list a bunch of groups at times, it can be very useful! No hard feelings if you never use it, though ;D Just figured I'd share in case ^^
|
|
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 Nov 30, 2016 18:56:47 GMT -8
For further clarification, and some corrections: && and || as stated mean 'and' and 'or respectively, but && means 'and' in an exclusionary sense, and || means 'or' in an inclusive sense.
So, X && Y tells the coding that both x AND y conditions must be met, or else the statement will return false.
If X is true and Y is true = Statement is True If X is true and Y is false = Statement is False If X is false and Y is true = Statement is False If X is false and Y is false = Statement is False
Whereas X || Y tells the coding that as long as EITHER X or Y is met, then the statement will return true.
If X is true and Y is true = Statement is True If X is true and Y is false = Statement is True If X is false and Y is true = Statement is True If X is false and Y is false = Statement is False
So in the above example of {if ($[user.group.id] >= 1 && $[user.group.id] <= 4) || ($[user.group.id] >= 26 && $[user.group.id] <= 29)}
The statement in English would read:
If (usergroup id is greater than or equal to one AND less than or equal to four), OR (usergroup id is less than or equal to 26 AND less than or equal to 29)
The way this is written means that for the green statement, both conditions MUST be fulfilled; this determines the beginning and end of the range, which is why both conditions need to be fulfilled in order for the statement to return true.
Then the code checks for the same for the pink statement, following the parameters.
Then lastly: If the query result falls under the range specified for EITHER the green or the pink range, then the code that follows will execute.
|
|
inherit
220772
0
Mar 24, 2023 21:43:23 GMT -8
Tiffy-Bean
I support plugin and theme makers rights to create themes and plugins that are paid for.
1,052
April 2015
tiffythecodingwhiz
|
Post by Tiffy-Bean on Nov 30, 2016 20:51:10 GMT -8
This is all very useful and I'm going to bookmark this thread. Thank you both for all your imput. It helps me a whole lot and I've began to implement some of this on my layout. It has helped. In essence, I have all my profiles personalized, so users get different layouts depending on rank/race/etc. So, it's really nice to be able to specify certain ones to do a certain way.
|
|
inherit
220772
0
Mar 24, 2023 21:43:23 GMT -8
Tiffy-Bean
I support plugin and theme makers rights to create themes and plugins that are paid for.
1,052
April 2015
tiffythecodingwhiz
|
Post by Tiffy-Bean on Dec 2, 2016 13:59:37 GMT -8
tried using {if ($[user.group.id] >= 2 && $[user.group.id] <= 50)}{else}$[shoutbox]{/if} but it didn't work. NOt sure what's wrong with it. It's still showing the shoutbox for all group ids. I want it to show as just usergroup 1 and guests.
|
|
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 2, 2016 14:03:58 GMT -8
tried using {if ($[user.group.id] >= 2 && $[user.group.id] <= 50)}{else}$[shoutbox]{/if} but it didn't work. NOt sure what's wrong with it. It's still showing the shoutbox for all group ids. I want it to show as just usergroup 1 and guests. It would be better if you specified who to show it for than who not since the list of who can access is shorter than who can't, rather than writing an else into it since you aren't actually instructing the code to show something different. try {if $[user.group.id] == 1 || $[current_user.is_guest]} $[shoutbox] {/if} Also your syntax is wrong, the parenthesis are unneeded as you're not selecting multiple ranges. Think of it as nesting. You have the overall if statement, then specific conditions within that statement; if you only have one condition (such as if x, if x||y, or if x&&y) you don't need to add more nests.
|
|
inherit
220772
0
Mar 24, 2023 21:43:23 GMT -8
Tiffy-Bean
I support plugin and theme makers rights to create themes and plugins that are paid for.
1,052
April 2015
tiffythecodingwhiz
|
Post by Tiffy-Bean on Dec 2, 2016 15:43:56 GMT -8
Showing up for guests, but not for user group 1. I think I get what you're saying. -.- I have so much to learn.
|
|
inherit
220772
0
Mar 24, 2023 21:43:23 GMT -8
Tiffy-Bean
I support plugin and theme makers rights to create themes and plugins that are paid for.
1,052
April 2015
tiffythecodingwhiz
|
Post by Tiffy-Bean on Dec 2, 2016 15:49:27 GMT -8
{if $[current_user.id] == "1"}$[shoutbox]{elseif $[current_user.id] =="219"}{elseif $[current_user.is_guest]} $[shoutbox]{else} {/if} worked..so I'm going to use that. <3 Thanks for all the help.
|
|
inherit
220772
0
Mar 24, 2023 21:43:23 GMT -8
Tiffy-Bean
I support plugin and theme makers rights to create themes and plugins that are paid for.
1,052
April 2015
tiffythecodingwhiz
|
Post by Tiffy-Bean on Dec 2, 2016 15:52:12 GMT -8
It essentially put a guest shoutbox that admins can check for guest questions without it bugging members...so I appreciate it.
|
|
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 2, 2016 16:09:18 GMT -8
It essentially put a guest shoutbox that admins can check for guest questions without it bugging members...so I appreciate it. I believe what was the issue with my first code was lack of quotes around the id -- can you give that a go by any chance? It should accomplish what you are looking for.
|
|
inherit
220772
0
Mar 24, 2023 21:43:23 GMT -8
Tiffy-Bean
I support plugin and theme makers rights to create themes and plugins that are paid for.
1,052
April 2015
tiffythecodingwhiz
|
Post by Tiffy-Bean on Dec 2, 2016 16:31:40 GMT -8
It essentially put a guest shoutbox that admins can check for guest questions without it bugging members...so I appreciate it. I believe what was the issue with my first code was lack of quotes around the id -- can you give that a go by any chance? It should accomplish what you are looking for. Sorry..I lied..it didn't work.
|
|
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 2, 2016 16:35:18 GMT -8
I believe what was the issue with my first code was lack of quotes around the id -- can you give that a go by any chance? It should accomplish what you are looking for. You're right. It worked. <3 Yay! Glad to hear it. For whatever it's worth it's almost always better to do an if statement rather than if/else if there is no "else" content to display, if that makes sense? Let me know if I can help further :3
|
|