XF 2.0 Conditional statement for styles?

ibrian

Well-known member
I'm trying to set up a widget to only appear in a particular style, and have followed the instructions in this thread: https://xenforo.com/community/threads/conditionals-for-widgets.137561/

1. Set up widget with advanced selected but no positions, which calls up a 2nd widget
2. 2nd widget has positions selected and conditional trigger

However, I can't figure out the conditional statement required for 2.

So far I've tried:

Code:
<xf:if is="$xf.visitor.style_id == X">
    <xf:widget key="widget_name" />
</xf:if>

Code:
<xf:if is="$style_id == 'x'">
    <xf:widget key="widget_name" />
  </xf:if>

but neither works - the widget still appears regardless of the style ID.

Could someone please advise what the conditional statement required for styles is, please? :)
 
Hmm, I'm using the UIX.2 theme, and trying to include widgets on a conditional basis, but aside from the above issue, I've struggling to get the conditional statement for node ID to work, as provided here: https://xenforo.com/community/resources/conditional-statements-for-xenforo-2.5795/

Is it possible that this is an issue with the style itself, or can the XF2 conditional statements be a little unreliable?

Or could it be simply that I'm doing something completely wrong?
 
The problem is simply not knowing what conditional to use for style ID - I can't find any documentation on that at the moment, so I'm bumbling in the dark a little. :)
 
I've tried disabling addons, but still no joy - I'm left wondering if it might be a server setting. I know there was a warning during the upgrade process about popen no being enabled in php.ini.

Anyway, I just tried to set up conditional statements for a widget again, and found the following error in the XF log. Although it mentions UIX.2, the conditionals weren't working in the default theme either. I'm not sure if it provides any pointers.

Code:
[LIST]
[*]ErrorException: Template error: Function th_nodeclasses_nodes is unknown
[*]src/XF/Template/Templater.php:859
[*]Generated by: Unknown account
[*]May 31, 2018 at 3:37 PM
[/LIST]
Stack trace
#0 [internal function]: XF\Template\Templater->handleTemplateError(512, 'Function th_nod...', '/home/sffchron/...', 859, Array)
#1 src/XF/Template/Templater.php(859): trigger_error('Function th_nod...', 512)
#2 internal_data/code_cache/templates/l1/s30/public/node_list_category.php(17): XF\Template\Templater->fn('th_nodeclasses_...', Array, true)
#3 src/XF/Template/Templater.php(662): XF\Template\Templater->{closure}(Object(ThemeHouse\UIX\XF\Template\Templater), Array, Array)
#4 internal_data/code_cache/templates/l1/s30/public/forum_list.php(30): XF\Template\Templater->callMacro('node_list_categ...', 'depth1', Array, Array)
#5 src/XF/Template/Templater.php(662): XF\Template\Templater->{closure}(Object(ThemeHouse\UIX\XF\Template\Templater), Array, Array)
#6 internal_data/code_cache/templates/l1/s30/public/forum_list.php(64): XF\Template\Templater->callMacro(NULL, 'node_list_entry', Array, Array)
#7 src/XF/Template/Templater.php(662): XF\Template\Templater->{closure}(Object(ThemeHouse\UIX\XF\Template\Templater), Array, Array)
#8 internal_data/code_cache/templates/l1/s30/public/forum_list.php(230): XF\Template\Templater->callMacro(NULL, 'node_list', Array, Array)
#9 src/XF/Template/Templater.php(1249): XF\Template\Templater->{closure}(Object(ThemeHouse\UIX\XF\Template\Templater), Array)
#10 src/XF/Template/Template.php(24): XF\Template\Templater->renderTemplate('public:forum_li...', Array)
#11 src/XF/Mvc/Renderer/Html.php(48): XF\Template\Template->render()
#12 src/XF/Mvc/Dispatcher.php(332): XF\Mvc\Renderer\Html->renderView('XF:Forum\\Listin...', 'public:forum_li...', Array)
#13 src/XF/Mvc/Dispatcher.php(303): XF\Mvc\Dispatcher->renderView(Object(XF\Mvc\Renderer\Html), Object(XF\Mvc\Reply\View))
#14 src/XF/Mvc/Dispatcher.php(44): XF\Mvc\Dispatcher->render(Object(XF\Mvc\Reply\View), 'html')
#15 src/XF/App.php(1931): XF\Mvc\Dispatcher->run()
#16 src/XF.php(328): XF\App->run()
#17 index.php(13): XF::runApp('XF\\Pub\\App')
#18 {main}
Request state
array(4) {
  ["url"] => string(1) "/"
  ["referrer"] => bool(false)
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(0) {
  }
}
 
Back
Top Bottom