XF 2.2 How to create a custom variables? That I can re-use on templates / template mod / advertising?

rdn

Well-known member
How to create several custom variables that I can re-use on templates / template mod / advertising?
All those variables will just store NODE IDs.

Instead of manually adding this kind of conditional:
<xf:if is="in_array($__globals.forum.node_id,['1','2','3','4','5'])">
<xf:if is="!in_array($__globals.forum.node_id,['1','2','3','4','5'])">

I need to create some custom conditional out of it, like:
<xf:if is="$private_forums">
<xf:if is="$public_forums">
<xf:if is="$optional_forums">

So it's easier for me to alter node ID for each variable on one place.
Thanks a lot.
 
Solution
I add it on PAGE_CONTAINER template, is that okay?
This might or might not work, depending on where you want to access the param.

XenForo template engine works like this:
The template to be used is defined in the controller by code like
PHP:
return $this->view($viewClass, $viewTemplate, $viewParams);

The defined template $viewTemplate (which might be smth. like thread_view does get rendered and while it is being rendered, all sub-templates/macros do get included.

Afterwards, template PAGE_CONTAINER does get rendered which does get the HTML of the rendered template as variable $content.

While rendering PAGE_CONTAINER, other templates (like the one for ad position...
You are most certainly doing smth. wrong as the condition should even work with XF 2.0.

Your HTML comment serms to output a string that looks like an array, if it was a array it should output snth. like

Code:
<!-- Node: 113 ; Config.php list: Array -->

Triple check your config.php code or post the snippet here.
 
  • Like
Reactions: rdn
Back
Top Bottom