Matte
New Member
Posts: 92
inherit
264111
0
Oct 21, 2024 20:35:25 GMT -8
Matte
92
April 2021
matte
|
Post by Matte on May 4, 2023 20:17:32 GMT -8
See recent replies. Some of this has been figured out. Thread title has been changed accordingly.
Title. I have a div set to display only inside a specific board. I'm able to have it display when viewing the board's thread list and when viewing a thread/post list inside the board, but can't seem to find a way to have it display on the posting page inside the board. Is this possible?
{if $[board.id] == 7 || $[thread.board.id] == 7} <div id="mySidenav" class="sidenav"> div content goes here </div> {/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
|
Post by Kami on May 4, 2023 22:45:47 GMT -8
Title. I have a div set to display only inside a specific board. I'm able to have it display when viewing the board's thread list and when viewing a thread/post list inside the board, but can't seem to find a way to have it display on the posting page inside the board. Is this possible? {if $[board.id] == 7 || $[thread.board.id] == 7} <div id="mySidenav" class="sidenav"> div content goes here </div> {/if} It looks like you'll want to also use a route (after declaring the board(s): support.proboards.com/thread/463090/new-route-names-templates
|
|
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,018
December 2005
horace
RedBassett's Mini-Profile
|
Post by Chris on May 4, 2023 22:49:53 GMT -8
Title. I have a div set to display only inside a specific board. I'm able to have it display when viewing the board's thread list and when viewing a thread/post list inside the board, but can't seem to find a way to have it display on the posting page inside the board. Is this possible? {if $[board.id] == 7 || $[thread.board.id] == 7} <div id="mySidenav" class="sidenav"> div content goes here </div> {/if} You should be able to access the board identifier when replying to an existing thread via the $[post.board.board_id] (for iterating over summary posts). As for generally querying that info on posting pages where a summary does not exist (e.g. on create new thread), I see no workaround. You would probably need to execute JavaScript during the page load in browser to make that determination. It exists as a client data in the pb('page').board.id metadata but not as a variable in layout(see Kami reply) On "new_thread" route the board_id exists as a param: $[route.params.board_id] == 44Other routes however such as "edit_post" or "quote_posts" do not carry a param bearing that info
|
|
Matte
New Member
Posts: 92
inherit
264111
0
Oct 21, 2024 20:35:25 GMT -8
Matte
92
April 2021
matte
|
Post by Matte on May 5, 2023 19:18:42 GMT -8
Kami , thanks for linking me to that page! Using $[route.params.board_id] == 7 takes care of both the thread list view and the "Create Thread" view in one swoop and eliminates the need for $[board.id] == 7. With the post list view already taken care of, I'm left with just the "replying to an existing thread" view (I'm ok with "edit post" and "quote post" view not adhering). Chris , I tried using $[post.board.board_id] == 7 but it doesn't seem to do it.
|
|
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,018
December 2005
horace
RedBassett's Mini-Profile
|
Post by Chris on May 5, 2023 22:56:47 GMT -8
Chris , I tried using $[post.board.board_id] == 7 but it doesn't seem to do it. Unfortunately, my only course of action would be to offer empathy in this case, given the lack of usable info. If you want some sort of diagnostics to "it doesn't seem to do it," then I'll probably need a bit more to go on than that (where, how, when...) - The $[post] variable in this context is used for iterating over summary posts (i.e. other posts that exist on the same page on which your reply was initiated or currently lives)
- "iterating" means it gets populated for each summary post within a for loop
- you need only to get the board_id of a single summary post to determine the board where the thread lives
|
|
Matte
New Member
Posts: 92
inherit
264111
0
Oct 21, 2024 20:35:25 GMT -8
Matte
92
April 2021
matte
|
Post by Matte on May 6, 2023 0:20:49 GMT -8
I was under the impression that the board_id was always going to be the same thing inside that board. The other variables referencing board_id equaled 7, so I assumed this one would do the same. I just tacked $[post.board.board_id] == 7 into the if statement and it didn't cause my div to display on the reply page. Full disclosure: I don't think I know enough about the loops and variables to know what I'm missing, so I'm going to go out on a limb here and say that this bit is over my head and I'll just have to deal with the div not displaying on the "replying to an existing thread" page. I appreciate the help.
|
|
Matte
New Member
Posts: 92
inherit
264111
0
Oct 21, 2024 20:35:25 GMT -8
Matte
92
April 2021
matte
|
Post by Matte on May 12, 2023 20:36:11 GMT -8
I did a little bit more poking around with this in my free time and was able to get $[post.board_id] == 7 to display the div on the "replying to an existing thread" page by copying my if statement and div html into the "Thread Summary" layout template. My goal was to have my if statement and div html only in the "Forum Wrapper" layout template because I want the div to display in every situation possible when inside the specific board, but my div has information that will need to be changed occasionally and I don't want to have to go into multiple layout templates to change it, if that makes sense. I tried everything I could think of (still not knowing much or having much experience using loops and variables) to no avail, so I assume there's no way to have this work inside the "Forum Wrapper" layout template. No way to basically say "if I'm on a page that has a thread summary on it and any of the posts within that summary is inside a board with id == 7, display the following"?
Here's what's in my "Forum Wrapper"{if $[route.params.board_id] == 7 || $[thread.board.id] == 7} <div id="mySidenav" class="sidenav"> <a id="divinfohere"> div information </div> {/if} Here's what's in my "Thread Summary"
{foreach $[post]} {if $[post.board_id] == 7} <div id="mySidenav" class="sidenav"> <a id="divinfohere"> div information </div> {/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 May 12, 2023 21:00:33 GMT -8
Sorry, trying to parse this but I am not sure I am succeeding.
For clarity: you are using something in the forum wrapper in order to display something in a specific board (in every form/page that board is capable of generating)?
|
|
Matte
New Member
Posts: 92
inherit
264111
0
Oct 21, 2024 20:35:25 GMT -8
Matte
92
April 2021
matte
|
Post by Matte on May 13, 2023 0:29:20 GMT -8
Sorry, trying to parse this but I am not sure I am succeeding. For clarity: you are using something in the forum wrapper in order to display something in a specific board (in every form/page that board is capable of generating)? That's correct. I'll explain to try to paint the full picture. My forum has a few different categories and one of them includes what's essentially a role-playing board. I'm making a little collapsible/expandable side tab to display the current champions in this role-playing board, but I don't want it to appear for someone who doesn't use the role-playing board. If they're visiting my forum to talk sports in the Football board, for example, I don't want the role-playing side tab to show up for them. As for why I decided to put my code for this in the "Forum Wrapper" layout template: the champions to be displayed in this side tab will change from time to time, so I want the contents of the div to be contained in one place so I don't have to jump around to multiple layout templates to edit it and be sure it's displaying consistently wherever it shows up. The code that I mentioned above in my "Forum Wrapper" successfully displays the div inside this board when viewing the thread list and when on the "Create Thread" posting page. The code inside my "Thread Summary" is the only way I found to successfully display the div when on the "replying to/editing/quoting an existing thread" posting page. matte.boards.net/ - To make it easier, you can see it in action here at my testing forum. The board titled "The OOWF" is the board I'm working with. If you enter that board, a little side tab should appear at the bottom left of the page. When you enter any other board, that tab does not appear. It's currently working how I want it to work, with the only issue being that I have to edit the code in two different layout templates whenever I want to update the list of champions. That's why I was hoping to find a way to relocate the foreach or if statement from my "Thread Summary" into my "Forum Wrapper", but nothing that I've tried has done the job.
|
|
Matte
New Member
Posts: 92
inherit
264111
0
Oct 21, 2024 20:35:25 GMT -8
Matte
92
April 2021
matte
|
Post by Matte on May 16, 2023 16:01:20 GMT -8
Just realized this thread was moved here from the Coding Help board. Figured I'd bump it to see if any template frequenters could be of help. Thread title also has been been changed to hopefully describe what I'm trying to figure out at this point (whether or not it's actually possible, mostly).
|
|
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,018
December 2005
horace
RedBassett's Mini-Profile
|
Post by Chris on May 24, 2023 20:03:53 GMT -8
A limitation of the Proboards templating system is that variables are tied to the template in which they are scoped. There are a few variables that are considered global since they can be accessed from any template (such as $[route] and $[current_user]), but the vast majority are scoped to their respective templates. A proper analogy would be considering the forum wrapper template as a house. The various sub-templates would be the rooms within that house, so whether you're in the kitchen or the bathroom you would still have a roof and a floor shared by all (a global variable). However, if you are in the kitchen and want to take a bath, you would need to head to the bathroom since there is no bathtub in the kitchen. The clever lodger might figure out how to take a bath in the kitchen sink or how to use a bucket and sponge in the bedroom, but the stated variables in the Loop and Variables inventory informs you that when you are in the bathroom there is a bathtub, sink and perhaps some other porcelain fixtures along with the commonly shared roof and floor. You can probably accomplish your ultimate goal of having a central location to place the content by using the <template /> tag (or just a plain div tag if that tickles your fancy) to store whatever content you want in a central location (within the forum wrapper) then modify your decision branches to grab the content via JavaScript to populate an empty <div id="mySidenav" class="sidenav" /> (which also lives in the forum wrapper) This could also be done much more seamlessly from the client side since JavaScript has access to the pb.data('page') metadata. This includes info on the current category, board, thread, etc., when viewing a page where such an hierarchy exists. Templates have no comparable variable, much like it had no $[route] variable for a time until it was borrowed from the JavaScript side [1]
|
|
Matte
New Member
Posts: 92
inherit
264111
0
Oct 21, 2024 20:35:25 GMT -8
Matte
92
April 2021
matte
|
Post by Matte on Jun 1, 2023 19:15:48 GMT -8
A limitation of the Proboards templating system is that variables are tied to the template in which they are scoped. There are a few variables that are considered global since they can be accessed from any template (such as $[route] and $[current_user]), but the vast majority are scoped to their respective templates. This is what I assumed was the case. I was pleasantly surprised to even be able to call to a thread.board.id from the forum wrapper template. Thanks for confirming it for me so I can stop trying to trick it into working! Unfortunately for me, I have zero knowledge of JavaScript, so unless someone with the time and the talent pops in here and takes it on, I'll be settling with what I've got.
|
|
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,018
December 2005
horace
RedBassett's Mini-Profile
|
Post by Chris on Jun 2, 2023 21:16:37 GMT -8
There are a couple existing plugins that might fit the bill
|
|
Matte
New Member
Posts: 92
inherit
264111
0
Oct 21, 2024 20:35:25 GMT -8
Matte
92
April 2021
matte
|
Post by Matte on Jun 5, 2023 19:44:06 GMT -8
It just struck me that I've been overthinking this! We've been limiting ourselves to using the more modern templating paradigm and totally forgetting about the old school, and still legitimate, headers/footers pattern which is not encumbered by the existence or non-existence of variables. I've never edited an individual board's header/footer, so yeah, this is something that I would not have found out on my own. It works! And it's easy! You've saved me such a headache! Thank you!
|
|