inherit
217348
0
Jul 27, 2022 7:26:44 GMT -8
Lynx
5,846
January 2015
msg
|
Post by Lynx on Oct 21, 2023 13:37:53 GMT -8
Hi! I'm having some slight issues with my template mod. Specifically in my: Admin > Themes > Layout Templates > Boards > Board List (tab)Forum URL: lynx-conan21.boards.net/Current (Default) Theme: Tribal - Library link: TribalCurrent code mod (Line 33): <td class="threads">{if ($[board.threads] == -1 && !$[current_user.is_member])}Private Board<br />(requires Login){elseif ($[boards.threads] == -1 && $[current_user.is_member])}N/A{else}$[board.threads]{/if}</td>
My goal is this: - If it's a Private Board AND the current user is not a member (guest), then display: Private Board (requires Login) - If it's a Private Board AND the current user is a logged-in member, then display: N/A - Otherwise, it's not a Private Board, so display normally. Problem is, it's displaying a 0 instead of N/A for logged in members - at least, for me. Is there something wrong with my code, or is it just because I'm looking at it from the main admin account? If it's something wrong, could you please point me to where my error is? Thank you!
|
|
Kami
Forum Cat
Posts: 40,198
Mini-Profile Theme: Kami's Mini-Profile
#f35f71
156500
0
Offline
Jul 24, 2021 11:48:29 GMT -8
Kami
40,198
July 2010
kamiyakaoru
Kami's Mini-Profile
|
Post by Kami on Oct 21, 2023 13:47:58 GMT -8
Hi! I'm having some slight issues with my template mod. Specifically in my: Admin > Themes > Layout Templates > Boards > Board List (tab)Forum URL: lynx-conan21.boards.net/Current (Default) Theme: Tribal - Library link: TribalCurrent code mod (Line 33): <td class="threads">{if ($[board.threads] == -1 && !$[current_user.is_member])}Private Board<br />(requires Login){elseif ($[boards.threads] == -1 && $[current_user.is_member])}N/A{else}$[board.threads]{/if}</td>
My goal is this: - If it's a Private Board AND the current user is not a member (guest), then display: Private Board (requires Login) - If it's a Private Board AND the current user is a logged-in member, then display: N/A - Otherwise, it's not a Private Board, so display normally. Problem is, it's displaying a 0 instead of N/A for logged in members - at least, for me. Is there something wrong with my code, or is it just because I'm looking at it from the main admin account? If it's something wrong, could you please point me to where my error is? Thank you! Maybe I'm being silly, but why are you using "-1" as the number of threads? Swap it to 0 and it should be fine, unless there's a reason.
|
|
inherit
217348
0
Jul 27, 2022 7:26:44 GMT -8
Lynx
5,846
January 2015
msg
|
Post by Lynx on Oct 21, 2023 13:58:35 GMT -8
Hi! I'm having some slight issues with my template mod. Specifically in my: Admin > Themes > Layout Templates > Boards > Board List (tab)Forum URL: lynx-conan21.boards.net/Current (Default) Theme: Tribal - Library link: TribalCurrent code mod (Line 33): <td class="threads">{if ($[board.threads] == -1 && !$[current_user.is_member])}Private Board<br />(requires Login){elseif ($[boards.threads] == -1 && $[current_user.is_member])}N/A{else}$[board.threads]{/if}</td>
My goal is this: - If it's a Private Board AND the current user is not a member (guest), then display: Private Board (requires Login) - If it's a Private Board AND the current user is a logged-in member, then display: N/A - Otherwise, it's not a Private Board, so display normally. Problem is, it's displaying a 0 instead of N/A for logged in members - at least, for me. Is there something wrong with my code, or is it just because I'm looking at it from the main admin account? If it's something wrong, could you please point me to where my error is? Thank you! Maybe I'm being silly, but why are you using "-1" as the number of threads? Swap it to 0 and it should be fine, unless there's a reason. I believe the -1 indicates that the board is a Private Board, as opposed to a non-private board with no posts. As such, the "Private Board (requires Login)" or "N/A" is to only show on Private Boards. That's why I used the -1. EDIT: Here's the actual line from a vanilla theme: <td class="threads">{if $[board.threads] == -1}N/A{else}$[board.threads]{/if}</td>
As you can see, it uses a -1 as well.
|
|
Kami
Forum Cat
Posts: 40,198
Mini-Profile Theme: Kami's Mini-Profile
#f35f71
156500
0
Offline
Jul 24, 2021 11:48:29 GMT -8
Kami
40,198
July 2010
kamiyakaoru
Kami's Mini-Profile
|
Post by Kami on Oct 21, 2023 15:09:11 GMT -8
Maybe I'm being silly, but why are you using "-1" as the number of threads? Swap it to 0 and it should be fine, unless there's a reason. I believe the -1 indicates that the board is a Private Board, as opposed to a non-private board with no posts. As such, the "Private Board (requires Login)" or "N/A" is to only show on Private Boards. That's why I used the -1. EDIT: Here's the actual line from a vanilla theme: <td class="threads">{if $[board.threads] == -1}N/A{else}$[board.threads]{/if}</td>
As you can see, it uses a -1 as well. Oh for some reason my brain didn't register "private board" as like, the actual board type as opposed to like, a board that is locked for members only. I've never worked with private boards template-wise; I wonder if a switcheroo would be helpful? Sometimes when something doesn't work with the variables I need it to, setting the default in the reverse helps. EG: right now you have: > if private + not member > if private + member > anything else What if you tried (and this is just a guess): > if everything else > if private + member > if private + not a member ?
|
|
inherit
Official Code Helper
65613
0
1
Oct 22, 2024 1:56:19 GMT -8
Chris
"'Oops' is the sound we make when we improve"
9,017
December 2005
horace
RedBassett's Mini-Profile
|
Post by Chris on Oct 21, 2023 22:06:19 GMT -8
As the admin, have you considered that you would never get a "-1" because no boards are off-limit to you? Have you tried viewing the modification as the other roles: regular member, guest, limited, and privileged groups?
Tried creating a single thread in that private board and see if you get a "1" instead of a "0"? Have someone else create a thread and see if you now get a "2".
|
|
inherit
217348
0
Jul 27, 2022 7:26:44 GMT -8
Lynx
5,846
January 2015
msg
|
Post by Lynx on Oct 22, 2023 5:53:08 GMT -8
I believe the -1 indicates that the board is a Private Board, as opposed to a non-private board with no posts. As such, the "Private Board (requires Login)" or "N/A" is to only show on Private Boards. That's why I used the -1. EDIT: Here's the actual line from a vanilla theme: <td class="threads">{if $[board.threads] == -1}N/A{else}$[board.threads]{/if}</td>
As you can see, it uses a -1 as well. Oh for some reason my brain didn't register "private board" as like, the actual board type as opposed to like, a board that is locked for members only. I've never worked with private boards template-wise; I wonder if a switcheroo would be helpful? Sometimes when something doesn't work with the variables I need it to, setting the default in the reverse helps. EG: right now you have: > if private + not member > if private + member > anything else What if you tried (and this is just a guess): > if everything else > if private + member > if private + not a member ? Thanks, Kami. I can certainly give that a try. As the admin, have you considered that you would never get a "-1" because no boards are off-limit to you?Have you tried viewing the modification as the other roles: regular member, guest, limited, and privileged groups? Tried creating a single thread in that private board and see if you get a "1" instead of a "0"? Have someone else create a thread and see if you now get a "2". I had considered that, Chris: Is there something wrong with my code, or is it just because I'm looking at it from the main admin account?I have never tinkered with that part of a template before, so I was unsure if me being on my main admin account would be the culprit or not. I haven't made a second account on that forum (it's a single account only forum), but I can certainly ask one of my regular members what they see there and possibly post a screenshot. Given the reason I highlighted in your quoted post above, I have no doubts that that is most likely the reason why. Thank you for your input!
|
|
inherit
217348
0
Jul 27, 2022 7:26:44 GMT -8
Lynx
5,846
January 2015
msg
|
Post by Lynx on Oct 23, 2023 6:28:07 GMT -8
Okay, I created a 2nd account (faster than waiting for a regular member to log on and check for me) and noticed that there's still an issue I have:
<td class="threads">{if ($[board.threads] == -1 && !$[current_user.is_member])}Private Board<br />(requires Login){elseif ($[boards.threads] == -1 && $[current_user.is_member])}N/A{else}$[board.threads]{/if}</td>
I get the Private Board when not logged in (so that part works correctly), but I'm getting a -1 instead of an N/A while logged in on a regular account. It's almost as if my {elseif} statement is being ignored or there's some sort of syntax error that I'm not seeing.
Any ideas? Thanks!
|
|
Kami
Forum Cat
Posts: 40,198
Mini-Profile Theme: Kami's Mini-Profile
#f35f71
156500
0
Offline
Jul 24, 2021 11:48:29 GMT -8
Kami
40,198
July 2010
kamiyakaoru
Kami's Mini-Profile
|
Post by Kami on Oct 23, 2023 8:00:47 GMT -8
Okay, I created a 2nd account (faster than waiting for a regular member to log on and check for me) and noticed that there's still an issue I have: <td class="threads">{if ($[board.threads] == -1 && !$[current_user.is_member])}Private Board<br />(requires Login){elseif ($[boards.threads] == -1 && $[current_user.is_member])}N/A{else}$[board.threads]{/if}</td>
I get the Private Board when not logged in (so that part works correctly), but I'm getting a -1 instead of an N/A while logged in on a regular account. It's almost as if my {elseif} statement is being ignored or there's some sort of syntax error that I'm not seeing. Any ideas? Thanks! I am like.... 85% sure that I saw a thread about this in the main Support Board; I'm going to look for it during my lunch break but feel free to browse if you have time / don't want to wait. If you can't find it that's OK I will look either way unless you find it first :)
|
|
inherit
Official Code Helper
65613
0
1
Oct 22, 2024 1:56:19 GMT -8
Chris
"'Oops' is the sound we make when we improve"
9,017
December 2005
horace
RedBassett's Mini-Profile
|
Post by Chris on Oct 23, 2023 10:06:24 GMT -8
I added the code to a test forum and then tested as guest, regular member and admin and had no issues. The Codes:For diagnostic purposes, perhaps you can refactor the coding so the test for access (-1) is an outer conditional while the test for logged in status is a separate inner conditional. The outer (access) conditional will have the fallback showing the thread count only if the viewing user can access the board without a permission error: If the affected user (secondary account) still does not get caught in one of the inner loop options, then it is much easier to narrow down why. What I Learned:- When the $[board.threads] variable returns -1 it signifies that the user can see the private board but has limited or no access to what is inside the board
- Guests can never post to a private board (there is no "everyone" option for create and reply)
The Test:The original code, as well as the refactored code, work equally well on the test forum (one is used in threads column, and the other is used in posts column yet still referencing the board.threads variable to keep things equal):
|
|
inherit
217348
0
Jul 27, 2022 7:26:44 GMT -8
Lynx
5,846
January 2015
msg
|
Post by Lynx on Oct 23, 2023 14:28:52 GMT -8
Thank you Kami and Chris! Refactoring to have the outer and inner conditionals did the trick - so thank you very much for that solution, Chris! This thread can be marked resolved.
|
|
Kami
Forum Cat
Posts: 40,198
Mini-Profile Theme: Kami's Mini-Profile
#f35f71
156500
0
Offline
Jul 24, 2021 11:48:29 GMT -8
Kami
40,198
July 2010
kamiyakaoru
Kami's Mini-Profile
|
Post by Kami on Oct 23, 2023 15:43:09 GMT -8
Thank you Kami and Chris ! Refactoring to have the outer and inner conditionals did the trick - so thank you very much for that solution, Chris ! This thread can be marked resolved. I feel like this was a more cohesive guide to what I had intended to say in my other post so super thanks to Chris for that from me too haha.
|
|