inherit
114253
0
Sept 23, 2024 7:58:54 GMT -8
Teg
Can't Wait for V6
3,157
November 2007
teg
|
If/Else
Sept 3, 2023 11:28:27 GMT -8
Post by Teg on Sept 3, 2023 11:28:27 GMT -8
Someone please guide me what I am doing wrong.
{if $[current_user.custom_field.name] == "House Points" && $[current_user.custom_field.value] != "0"} $[current_user.custom_field.value] {else} <a href="https://hwsoww.boards.net/board/5/sorting-ceremony">Get Sorted</a>{/if}
It' consistently puts the "Get Sorted" link, even though the number in the custom field value is over 1000.
|
|
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
|
If/Else
Sept 3, 2023 11:36:22 GMT -8
Post by Kami on Sept 3, 2023 11:36:22 GMT -8
Someone please guide me what I am doing wrong. {if $[current_user.custom_field.name] == "House Points" && $[current_user.custom_field.value] != "0"} $[current_user.custom_field.value] {else} <a href="https://hwsoww.boards.net/board/5/sorting-ceremony">Get Sorted</a>{/if}
It' consistently puts the "Get Sorted" link, even though the number in the custom field value is over 1000. You're using "current_user"; is this intentional? This would pull the custom field values of the account *viewing* the section, as opposed to the account to whom the section belongs.
|
|
inherit
114253
0
Sept 23, 2024 7:58:54 GMT -8
Teg
Can't Wait for V6
3,157
November 2007
teg
|
If/Else
Sept 3, 2023 11:40:54 GMT -8
Post by Teg on Sept 3, 2023 11:40:54 GMT -8
I figured it out, forgot the for each but, yes, it is intentional, it should only be for the current user who is viewing the page. Someone please guide me what I am doing wrong. {if $[current_user.custom_field.name] == "House Points" && $[current_user.custom_field.value] != "0"} $[current_user.custom_field.value] {else} <a href="https://hwsoww.boards.net/board/5/sorting-ceremony">Get Sorted</a>{/if}
It' consistently puts the "Get Sorted" link, even though the number in the custom field value is over 1000. You're using "current_user"; is this intentional? This would pull the custom field values of the account *viewing* the section, as opposed to the account to whom the section belongs.
|
|
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
|
If/Else
Sept 3, 2023 12:36:06 GMT -8
Post by Kami on Sept 3, 2023 12:36:06 GMT -8
I figured it out, forgot the for each but, yes, it is intentional, it should only be for the current user who is viewing the page. You're using "current_user"; is this intentional? This would pull the custom field values of the account *viewing* the section, as opposed to the account to whom the section belongs. ahh got it, foreach was gonna be my next question but i had (erroneously it seems) assumed you were only showing a snippet and already had it 😅 glad you got it sorted!
|
|
inherit
114253
0
Sept 23, 2024 7:58:54 GMT -8
Teg
Can't Wait for V6
3,157
November 2007
teg
|
If/Else
Sept 4, 2023 10:47:01 GMT -8
Post by Teg on Sept 4, 2023 10:47:01 GMT -8
it has been a hot minute since i have done anything with pb, so i forgot lol thank you though. I am curious, is there a way to write an if/else statement to say the following If current user group name does not equal group1 group2 group3 or group4, then this happens? I figured it out, forgot the for each but, yes, it is intentional, it should only be for the current user who is viewing the page. ahh got it, foreach was gonna be my next question but i had (erroneously it seems) assumed you were only showing a snippet and already had it 😅 glad you got it sorted!
|
|
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
|
If/Else
Sept 4, 2023 11:33:18 GMT -8
Post by Kami on Sept 4, 2023 11:33:18 GMT -8
it has been a hot minute since i have done anything with pb, so i forgot lol thank you though. I am curious, is there a way to write an if/else statement to say the following If current user group name does not equal group1 group2 group3 or group4, then this happens? ahh got it, foreach was gonna be my next question but i had (erroneously it seems) assumed you were only showing a snippet and already had it 😅 glad you got it sorted! if [variable] != group1 || [variable] != group2 etc. the double pipe || is an inclusive "or" for "if any of these are true", then execute
|
|
inherit
114253
0
Sept 23, 2024 7:58:54 GMT -8
Teg
Can't Wait for V6
3,157
November 2007
teg
|
Post by Teg on Sept 4, 2023 12:08:55 GMT -8
Awesome, thank you! I'll try that out and see how I fare I appreciate the guidance. it has been a hot minute since i have done anything with pb, so i forgot lol thank you though. I am curious, is there a way to write an if/else statement to say the following If current user group name does not equal group1 group2 group3 or group4, then this happens? if [variable] != group1 || [variable] != group2 etc. the double pipe || is an inclusive "or" for "if any of these are true", then execute
|
|
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
|
If/Else
Sept 4, 2023 12:48:24 GMT -8
Post by Kami on Sept 4, 2023 12:48:24 GMT -8
Awesome, thank you! I'll try that out and see how I fare I appreciate the guidance. if [variable] != group1 || [variable] != group2 etc. the double pipe || is an inclusive "or" for "if any of these are true", then execute yeah np -- note that you need to wrap the group names in quotes if you use that, or use group ID numbers instead.
|
|
inherit
217348
0
Jul 27, 2022 7:26:44 GMT -8
Lynx
5,849
January 2015
msg
|
If/Else
Sept 4, 2023 17:11:47 GMT -8
Post by Lynx on Sept 4, 2023 17:11:47 GMT -8
If I may - if your check is to say "the current user cannot be in Group1, Group2, Group3 or Group4 (the user cannot be in any of those groups), then you're going to want to use && (and) in that scenario:
if $[variable] != "Group1" && $[variable] != "Group2" && $[variable] != "Group3" && $[variable] != "Group4"
What gets used (|| or &&) depends on the code that follows the if statement. In most cases, I've found I'm using && if I'm also using != and I'm using || when I'm using ==. So, the question to be answered is:
Is the code that follows the if to apply if the current user cannot be in any of those groups (the user cannot be in Group1, Group2, Group3 nor Group4) or are you only concerned if they are not in just one of those groups (but can be in of the other 3)?
|
|
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 Sept 4, 2023 17:49:10 GMT -8
If I may - if your check is to say "the current user cannot be in Group1, Group2, Group3 or Group4 (the user cannot be in any of those groups), then you're going to want to use && (and) in that scenario: if $[variable] != "Group1" && $[variable] != "Group2" && $[variable] != "Group3" && $[variable] != "Group4"
What gets used (|| or &&) depends on the code that follows the if statement. In most cases, I've found I'm using && if I'm also using != and I'm using || when I'm using ==. So, the question to be answered is: Is the code that follows the if to apply if the current user cannot be in any of those groups (the user cannot be in Group1, Group2, Group3 nor Group4) or are you only concerned if they are not in just one of those groups (but can be in of the other 3)? I see your logic but my thinking was that I haven't had much luck targeting groups that are not chosen to display on the user's profile. I know it's possible in javascript but in the past i've had to use [or] instead of [and] as the check seems to only work in templates for what is displayed I could be VERY wrong though, it's been a minute since I tested & I don't have a desktop rn to check.
|
|
inherit
114253
0
Sept 23, 2024 7:58:54 GMT -8
Teg
Can't Wait for V6
3,157
November 2007
teg
|
If/Else
Sept 5, 2023 10:17:29 GMT -8
Post by Teg on Sept 5, 2023 10:17:29 GMT -8
Now I'm having an issue with:
{foreach $[current_user.custom_field]} {if $[current_user.custom_field.name] == "Store"} {if $[current_user.custom_field.value] != ""} <li> <a href="$[current_user.custom_field.value]" title="My Store">My Store</a> </li> {else} <li> <a href="#" title="Open A Store">Open A Store</a> </li> {/if} {/if} {/foreach}
so the != "" should represent empty but it's not registering that. Is there something I am missing?
Then for whatever reason I cannot get the private messages number total to display using this...
<a href="$[current_user.messages.inbox]" title="Private Messages">Owlry</a> {if $[current_user.messages.new]} <span class="sidebar-notification">$[current_user.new_notification] </span> {/if}
|
|
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
|
If/Else
Sept 5, 2023 10:25:31 GMT -8
Teg likes this
Post by Kami on Sept 5, 2023 10:25:31 GMT -8
Now I'm having an issue with: {foreach $[current_user.custom_field]} {if $[current_user.custom_field.name] == "Store"} {if $[current_user.custom_field.value] != ""} <li> <a href="$[current_user.custom_field.value]" title="My Store">My Store</a> </li> {else} <li> <a href="#" title="Open A Store">Open A Store</a> </li> {/if} {/if} {/foreach}
so the != "" should represent empty but it's not registering that. Is there something I am missing? Unfortunately you cannot target a custom field that has not been filled in as it isn't even available — even if you are trying to target it because it is empty, since lack of entry means the value does not exist which means it cannot be targeted. The workaround is really messy as well. You would have to define an element that exists outside of the foreach loop with a class name, then set that class between a foreach loop and if the custom field is present, then use CSS to say that class should be hidden. This way, you have an element that shows UNLESS the field is filled. Does that make sense?
|
|
inherit
114253
0
Sept 23, 2024 7:58:54 GMT -8
Teg
Can't Wait for V6
3,157
November 2007
teg
|
If/Else
Sept 5, 2023 12:43:06 GMT -8
Post by Teg on Sept 5, 2023 12:43:06 GMT -8
Now I'm having an issue with: {foreach $[current_user.custom_field]} {if $[current_user.custom_field.name] == "Store"} {if $[current_user.custom_field.value] != ""} <li> <a href="$[current_user.custom_field.value]" title="My Store">My Store</a> </li> {else} <li> <a href="#" title="Open A Store">Open A Store</a> </li> {/if} {/if} {/foreach}
so the != "" should represent empty but it's not registering that. Is there something I am missing? Unfortunately you cannot target a custom field that has not been filled in as it isn't even available — even if you are trying to target it because it is empty, since lack of entry means the value does not exist which means it cannot be targeted. The workaround is really messy as well. You would have to define an element that exists outside of the foreach loop with a class name, then set that class between a foreach loop and if the custom field is present, then use CSS to say that class should be hidden. This way, you have an element that shows UNLESS the field is filled. Does that make sense? Yeah that seems like a bit much for something that should be so simple. It does make sense though. Any idea on the second problem in that same post?
|
|
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
|
If/Else
Sept 5, 2023 13:40:25 GMT -8
Teg likes this
Post by Kami on Sept 5, 2023 13:40:25 GMT -8
Unfortunately you cannot target a custom field that has not been filled in as it isn't even available — even if you are trying to target it because it is empty, since lack of entry means the value does not exist which means it cannot be targeted. The workaround is really messy as well. You would have to define an element that exists outside of the foreach loop with a class name, then set that class between a foreach loop and if the custom field is present, then use CSS to say that class should be hidden. This way, you have an element that shows UNLESS the field is filled. Does that make sense? Yeah that seems like a bit much for something that should be so simple. It does make sense though. Any idea on the second problem in that same post? Yeah I dont super advise it unless you for sure need to have information displayed when the field is blank. For the second issue, I am admittedly not the best when it comes to message notifications as I usually swap them out for a numberless indicator. elli might be able to help, but I am not sure how often her schedule will allow. Unfortunately since I don't have a PC at this time, I can't do any investigative work to assist in troubleshooting.
|
|
inherit
96289
0
May 17, 2020 9:37:00 GMT -8
elli
1,822
January 2007
ebbymac
|
Post by elli on Sept 6, 2023 18:35:28 GMT -8
elli might be able to help, but I am not sure how often her schedule will allow. Unfortunately since I don't have a PC at this time, I can't do any investigative work to assist in troubleshooting. Then for whatever reason I cannot get the private messages number total to display using this... <a href="$[current_user.messages.inbox]" title="Private Messages">Owlry</a> {if $[current_user.messages.new]} <span class="sidebar-notification">$[current_user.new_notification]</span> {/if} It looks like you're just missing the 's' on the end: $[current_user.new_notification s]
|
|