inherit
246391
0
Aug 24, 2023 11:49:12 GMT -8
regack
24
July 2017
regack
|
Post by regack on Sept 8, 2018 8:17:02 GMT -8
So within the templates, I know I've got the IF/ELSEIF/ELSE and FOREACH... are there any other functions available? I've tried searching, but I... apparently am not good at searching?
Is there a guide I missed that covers the functions & syntax?
I created a series of if/foreach statements to do what I want, and it's working fine, but there should be a way to slim down the logic I could just directly reference the element within the array (my terminology, not necessarily how it's structured) or I knew more about the syntax.
like: $[current_user.custom_field[0].name] because I know I always want the name from the first item in the list - I could skip the foreach loops...
{if $[current_user.custom_field]}
{foreach $[current_user.custom_field]}
{if $[current_user.custom_field.index] == 0 && $[current_user.custom_field.name] == "SETTING"}
{if $[current_user.custom_field.value] == "VALUE"} Thing1 {/if}
{elseif $[current_user.custom_field.index] == 0 && $[current_user.custom_field.name] != "SETTING"}
Thing2 {/if}
{/foreach}
{else}
Thing3 {/if}
It looks like this is also a valid test: {if !$[current_user.custom_field]}
{/if}
Thanks in advance for any reference material or whatnot!
|
|
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 Sept 10, 2018 10:55:15 GMT -8
To my knowledge, foreach loops are mandatory for pulling out individual custom profile fields. There is not any shortcut that I'm aware of. You can have a maximum of something like 30 {foreach} loops per template and it is best to try to find a way to consolidate them as much as possible, putting as many needed {if}s as possible within the {foreach}, but I don't believe there is currently a way to skip this -- at least through native ability. Javascript and such always has a different way of handling things, but I'm not experienced in JS and can't advise for that, only for the variables and HTML side of things.
You can use ! for the inverse, yes, as well as == || && and I want to say != but I'm not sure on the last one. I never use it. xD Not many things require a loop -- it is either only profile fields or nearly only. I know it can be really rough. My mini-profile layout template is obnoxious, absolutely obnoxious, and I know finding a way to handle the many {foreach} and {if}s is aggravating and can be confusing, time-consuming, and require a lot of creative workarounds.
If there's something you need specific help with, you can always ask! Like a particular chunk of code that isn't working or you aren't sure how to write.
Pardon me if I misunderstood the OP and I'm sure someone will correct me if I turn out to be wrong :)
|
|
inherit
246391
0
Aug 24, 2023 11:49:12 GMT -8
regack
24
July 2017
regack
|
Post by regack on Sept 10, 2018 12:15:43 GMT -8
To my knowledge, foreach loops are mandatory for pulling out individual custom profile fields. There is not any shortcut that I'm aware of. You can have a maximum of something like 30 {foreach} loops per template and it is best to try to find a way to consolidate them as much as possible, putting as many needed {if}s as possible within the {foreach}, but I don't believe there is currently a way to skip this -- at least through native ability. Javascript and such always has a different way of handling things, but I'm not experienced in JS and can't advise for that, only for the variables and HTML side of things. You can use ! for the inverse, yes, as well as == || && and I want to say != but I'm not sure on the last one. I never use it. xD Not many things require a loop -- it is either only profile fields or nearly only. I know it can be really rough. My mini-profile layout template is obnoxious, absolutely obnoxious, and I know finding a way to handle the many {foreach} and {if}s is aggravating and can be confusing, time-consuming, and require a lot of creative workarounds. If there's something you need specific help with, you can always ask! Like a particular chunk of code that isn't working or you aren't sure how to write. Pardon me if I misunderstood the OP and I'm sure someone will correct me if I turn out to be wrong Thanks, I've been working with the {foreach} and it's fine, I was just hoping there might be some additional functions that I couldn't find listed anywhere. Again, thanks for the reply.
|
|
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 Sept 10, 2018 14:05:30 GMT -8
|
|
#eb7100
33409
0
1
Nov 13, 2024 16:56:46 GMT -8
Brian
48,130
November 2004
smashmaster3
|
Post by Brian on Sept 10, 2018 15:41:25 GMT -8
You've pretty much got all of it down. To give you a comprehensive overview our layout templates support the following control blocks: {if} {foreach} {elseif} {else}Which support the following operators: < <= > >= == != && ||As well as just !$[variable] by itself to do things like this: To expand on what ₪» ⅀ ƪ Ƒ «₪ posted you can have a maximum of 500 variables, 500 control blocks, and 30 foreach loops within a single template. To answer your other question, the layout templates don't currently support picking out a single array index without the use of both a foreach loop and an if statement.
|
|