L3010
New Member
Posts: 49
inherit
264353
0
Mar 4, 2023 7:57:32 GMT -8
L3010
49
May 2021
l3010
|
Post by L3010 on Jun 12, 2021 4:48:18 GMT -8
Hi!
I have a question, looking at the PB-stylesheets (forum wrapper, etc.) the code " $[] " is used in many places. Sometimes inside of an if-statement as if it where a variable and sometimes in code as if it would be a function.
These are some questions:
• Where can i find the code these codes are running?
• Are there a part of jQuerry?
• Where can i learn about these? • Can i create my own codes like these?
Examples of these codes used like functions: $[content] $[shoutbox] $[header]
Examples of these codes used like variables:
{if $[is_mobile_browser]} <br /><p class="center mobile-view-prompt">Switch to the $[mobile_switch_link].</p> {/if}
If anyone could explain this to me i would be very happy / Leo
|
|
inherit
140147
0
Nov 19, 2024 5:07:22 GMT -8
Nscalerr
Throw me to the wolves and I'll return leading the pack!
3,043
May 2009
nscalerr
|
Post by Nscalerr on Jun 12, 2021 6:54:08 GMT -8
Hi L3010First off they are in the templates, not the stylesheet. They are a way to have what would normally take several lines of javascript to be placed in the template. I am not 100% sure, but I think it is Json code and it is not possible to create your own ones, (as far as I know). When they are used as variables, it is another way of doing scripting that doesn't take up lots of space in the template.
|
|
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 Jun 12, 2021 10:09:39 GMT -8
Hi L3010 First off they are in the templates, not the stylesheet. They are a way to have what would normally take several lines of javascript to be placed in the template. I am not 100% sure, but I think it is Json code and it is not possible to create your own ones, (as far as I know). When they are used as variables, it is another way of doing scripting that doesn't take up lots of space in the template. It's not json. PB variables are their own, unique thing and are PB-specific. Some aspects (such as conditional statements) are reminiscent of other languages in terms of structure or syntax, but it is not a 1:1 correlation. While PB does allow plug-in creators to utilise the jquery library (if I recall correctly), that is separate from the template variables as well. For whatever it's worth, Pb is also written in perl. It is worth noting that $[] is ALWAYS a variable in PB templates. Using a conditional statement doesn't change that; $[content] is a variable as a for instance — the output is variable based on what page you're on — and you can also create a conditional using that variable. Whether or not it executes is dependent on whether or not your condition is true or aligns with the purpose / content of the variable (sometimes variables simply output a string, like the login/register variables, which are still variables but strings are always evaluated as a specific result). It isn't always for "scripting" necessarily either. For example, $[content] in the forum wrapper refers to anything placed (depending on page) in the other templates (eg: home or board), and isn't so much "scripting" but avoiding redundancy by referencing another page instead of having multiple templates with identical content. I suppose you could call it "scripting" in that in the end, this is fed back to the software which then outputs the correct content, but that would broadly apply to a lot of things
|
|
L3010
New Member
Posts: 49
inherit
264353
0
Mar 4, 2023 7:57:32 GMT -8
L3010
49
May 2021
l3010
|
Post by L3010 on Jun 14, 2021 0:52:38 GMT -8
Is there a place where you can see the code/use of all pb-variables, like a documentation?
Edit: Is there an introduction to pb-variables somewhere? (pdf document)
|
|
inherit
140147
0
Nov 19, 2024 5:07:22 GMT -8
Nscalerr
Throw me to the wolves and I'll return leading the pack!
3,043
May 2009
nscalerr
|
Post by Nscalerr on Jun 14, 2021 1:47:46 GMT -8
Not that I know of, for both questions.
The only place you can use the variables is in the templates and it is not possible to see the code behind the variable itself.
|
|
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 Jun 14, 2021 9:33:01 GMT -8
Confirming there's no documentation. It was planned in the early days of v5 but bugs and software improvements took priority; now that we're approaching the release of v6 (exact date TBD) it's no longer on the deck for v5 as it would be a lot of effort for something that would be (relatively) quickly deprecated.
My advice is to create a test forum and play with it to see what does what. If you need help / have questions, you can always post back here (:
|
|
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 Jun 14, 2021 10:17:46 GMT -8
I wanted to add:
> it's not possible to see the code behind the variable itself.
That's only partially true. You can play around in the templates and just use the variable by itself to see what value it outputs. Some variables will output a binary value (0 or 1) if it's something that checks whether or not something exists, others will output a constant value (like a link) if it's a variable that outputs a string, others will output a variable value (like custom profile fields), etc etc.
|
|
L3010
New Member
Posts: 49
inherit
264353
0
Mar 4, 2023 7:57:32 GMT -8
L3010
49
May 2021
l3010
|
Post by L3010 on Jun 16, 2021 10:09:32 GMT -8
Hello! I want to tell everyone that i found a way to directly see the code executed by the "$[]"-variables!!!
While in your browser and at the home page of a PB-forum, open "Inspect Element" (Different for every browser). This lets you see the html / css / js of the website you're on.
In Firefox, while at debugger,
Go to Main thread > (forum name).boards.net > "(index)" --- you will see a copy of the "ForumWrapper" HTML-file but with all "$[]"-variables "translated" into html!
For example: The "$[head]"-PB-variable executes 109 hidden lines of code containing at least 8 <script> tags in ForumWrapper!
I find this really useful!
|
|
L3010
New Member
Posts: 49
inherit
264353
0
Mar 4, 2023 7:57:32 GMT -8
L3010
49
May 2021
l3010
|
Post by L3010 on Jun 16, 2021 10:25:59 GMT -8
I have to mention that {if}{if/} tags will not show up in the "translated" file if the condition says to not execute code within the tag.
Example: {if $[maintenance_mode]} <div class="maintenance-header"> {if $[can.disable_maintenance]}<p>Finished with maintenance? $[disable_maintenance_link].</p>{/if} </div> {/if} This code will not exist in the "translated" file because i have maintenance mode disabled.
Example 2:
{if $[navigation.tree]} <div id="navigation-tree"> $[navigation.tree] </div> {/if}
This will show up translated because i have the navigation tree enabled
|
|
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 Jun 16, 2021 11:05:30 GMT -8
Yes, that is one way. However my comment was more for a ProBoards-supplied documentation, sorry for any confusion!
|
|