Former Member
inherit
guest@proboards.com
253222
0
Apr 26, 2024 2:47:43 GMT -8
Former Member
0
January 1970
Former Member
|
Post by Former Member on Jun 19, 2019 10:01:36 GMT -8
Hi. I was just curious what the PB Variable $[route] can do. Can someone please explain it to me?
|
|
#eb7100
33409
0
1
Apr 14, 2024 15:59:10 GMT -8
Brian
48,129
November 2004
smashmaster3
|
Post by Brian on Jun 19, 2019 11:16:14 GMT -8
$[route] contains information about the type of page you're on. The $[route] variable itself doesn't do anything, but its subvariables have use.
$[route.name] can be used to distinguish between different types of pages. Its value will change depending on whether you're looking at the index page, a board, a thread, the posting page, etc.
$[route.params.page_id] does the same thing but for custom pages. The value it outputs will reflect the ID of the custom page you're currently viewing, assuming you're viewing one.
There's at least one more param that can show up, but again, it depends entirely on the page you're looking at. If you open your browser's console (usually by pressing F12) you can type in pb.data('route') to see what the $[route] variable will contain on that page.
|
|
Former Member
inherit
guest@proboards.com
253222
0
Apr 26, 2024 2:47:43 GMT -8
Former Member
0
January 1970
Former Member
|
Post by Former Member on Jun 19, 2019 11:37:54 GMT -8
$[route] contains information about the type of page you're on. The $[route] variable itself doesn't do anything, but its subvariables have use. $[route.name] can be used to distinguish between different types of pages. Its value will change depending on whether you're looking at the index page, a board, a thread, the posting page, etc. $[route.params.page_id] does the same thing but for custom pages. The value it outputs will reflect the ID of the custom page you're currently viewing, assuming you're viewing one. There's at least one more param that can show up, but again, it depends entirely on the page you're looking at. If you open your browser's console (usually by pressing F12) you can type in pb.data('route') to see what the $[route] variable will contain on that page. So you could do: {if $[route.name] == "Home"} This is home {/if} ?
|
|
#eb7100
33409
0
1
Apr 14, 2024 15:59:10 GMT -8
Brian
48,129
November 2004
smashmaster3
|
Post by Brian on Jun 19, 2019 12:00:12 GMT -8
Yes, but it's case-sensitive, so "Home" wouldn't work because the route name is "home" (all lowercase).
|
|
Former Member
inherit
guest@proboards.com
253222
0
Apr 26, 2024 2:47:43 GMT -8
Former Member
0
January 1970
Former Member
|
Post by Former Member on Jun 19, 2019 12:17:09 GMT -8
Okay thanks!
|
|
inherit
249732
0
Feb 26, 2022 5:48:02 GMT -8
Sam
Typing...
135
October 2017
samzi
|
Post by Sam on Jun 21, 2019 3:51:08 GMT -8
Yes, but it's case-sensitive, so "Home" wouldn't work because the route name is "home" (all lowercase). How would this work with board names?
|
|
inherit
223590
0
May 17, 2023 9:13:21 GMT -8
Kitty Katt
My Username is @kittykatt (with 2 t's in katt)
819
July 2015
kittykatt
|
Post by Kitty Katt on Jun 21, 2019 6:03:28 GMT -8
Yes, but it's case-sensitive, so "Home" wouldn't work because the route name is "home" (all lowercase). How would this work with board names? I read this post and it would seem like it is possible to use board ID's, such as: {if $[route.params.board_id] == 44}I'm viewing the ProBoards Support Board!{/if}
with the board ID of 44 being the ID of the Support Board here on ProBoards. Naturally, you would use your own board ID for the board in question.
|
|
Former Member
inherit
guest@proboards.com
253222
0
Apr 26, 2024 2:47:43 GMT -8
Former Member
0
January 1970
Former Member
|
Post by Former Member on Jun 30, 2019 9:48:49 GMT -8
So, what would $[route.params.board_id] 's equivalent be in JS?
|
|
inherit
217348
0
Jul 27, 2022 7:26:44 GMT -8
Lynx
5,779
January 2015
msg
|
Post by Lynx on Jun 30, 2019 14:30:45 GMT -8
So, what would $[route.params.board_id] 's equivalent be in JS? pb.data('route').board_id
|
|
Former Member
inherit
guest@proboards.com
253222
0
Apr 26, 2024 2:47:43 GMT -8
Former Member
0
January 1970
Former Member
|
Post by Former Member on Jun 30, 2019 17:59:47 GMT -8
So, what would $[route.params.board_id] 's equivalent be in JS? pb.data('route').board_id
pb.data('route').board_name Could that work?
|
|
inherit
249732
0
Feb 26, 2022 5:48:02 GMT -8
Sam
Typing...
135
October 2017
samzi
|
Post by Sam on Jun 30, 2019 23:01:46 GMT -8
pb.data('route').board_id
pb.data('route').board_name Could that work? You may need to try both, because I'm not sure if it will output the name or id.
|
|