inherit
249732
0
Feb 26, 2022 5:48:02 GMT -8
Sam
Typing...
135
October 2017
samzi
|
Post by Sam on Feb 20, 2019 6:09:31 GMT -8
Hey, I was wondering if it's possible to make custom variables like you can get '$[board]' or '$[pagination].' Essentially is it possible for me to make my own, like '$[cake.text]' or something. Is this possible without a plugin? If it's not, how do I make a plugin do that?
|
|
inherit
217348
0
Jul 27, 2022 7:26:44 GMT -8
Lynx
5,775
January 2015
msg
|
Post by Lynx on Feb 20, 2019 7:29:44 GMT -8
Hey, I was wondering if it's possible to make custom variables like you can get '$[board]' or '$[pagination].' Essentially is it possible for me to make my own, like '$[cake.text]' or something. Is this possible without a plugin? If it's not, how do I make a plugin do that? var fullText = text.replace(/\$\[boardname\]/gi, currentBoard).replace(/\$\[category\]/gi, currentCategory);
text is taken from the plugin settings for a text line that is entered. An example text line could be: You are browsing the $[boardname] board. The .replace is going to allow us to replace old text with new text. It's using RegEx to get all occurrences of $[boardname] and replacing it with the actual board's name (of which the variable currentBoard is holding). The second .replace is doing the same for the Category name.
|
|
inherit
249732
0
Feb 26, 2022 5:48:02 GMT -8
Sam
Typing...
135
October 2017
samzi
|
Post by Sam on Feb 20, 2019 7:54:38 GMT -8
Hey, I was wondering if it's possible to make custom variables like you can get '$[board]' or '$[pagination].' Essentially is it possible for me to make my own, like '$[cake.text]' or something. Is this possible without a plugin? If it's not, how do I make a plugin do that? var fullText = text.replace(/\$\[boardname\]/gi, currentBoard).replace(/\$\[category\]/gi, currentCategory);
text is taken from the plugin settings for a text line that is entered. An example text line could be: You are browsing the $[boardname] board. The .replace is going to allow us to replace old text with new text. It's using RegEx to get all occurrences of $[boardname] and replacing it with the actual board's name (of which the variable currentBoard is holding). The second .replace is doing the same for the Category name. But this is only re-naming. I want to make an entirely new variable.
|
|
inherit
217348
0
Jul 27, 2022 7:26:44 GMT -8
Lynx
5,775
January 2015
msg
|
Post by Lynx on Feb 20, 2019 7:58:31 GMT -8
I don't think that's possible, but wait for a red to confirm. I'll tag Matej and Brian - one of them should be able to tell you if it's possible or not for certain.
|
|
#eb7100
33409
0
1
Apr 14, 2024 15:59:10 GMT -8
Brian
48,129
November 2004
smashmaster3
|
Post by Brian on Feb 20, 2019 9:42:57 GMT -8
All of the layout template variables are hard-coded. It's not possible to add new ones. The only exception to this is if you add a custom image to a theme in Themes > Theme Manager, after which a variable will appear in the variable tree that represents that image if you expand the theme variable in the list. Lynx's answer is correct. While they wouldn't truly be variables and would only be replaced following the page load a plugin can attempt to duplicate this functionality through the use of regular expressions. One of my own plugins does just that, albeit only within content that it added to the page.
|
|