• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XenOptions not working in Template Modifications Find

cclaerhout

Well-known member
#21
So what should happen is that the "Find:" should have a value of "Position 1", and should be be replaced by the contents in the "Replace:" box.
No, what should happen is the $xenOptions.trafficPosition is not found (its text in the template), then nothing happens. By the way, even if the template find/replace system would use variable values (which is NOT the case), I don't understand how it would suppose to find the all "<xen:comment>" line.
 

AndyB

Well-known member
#24
That's how template modifications work.
Would it be possible to make the {$xenOptions.foobar} in the Template Modifications "Find" field work by extending a class?

Another question, would it be possible to achieve a way to order sidebar add-ons in any way that would allow admins to simply change a value in the add-ons Options page.
 

Chris D

XenForo developer
Staff member
#25
Code:
<xen:if is="{$xenOptions.position} == '1'">
    Position 1
</xen:if>
Simple as that. One TM for each position.
 

AndyB

Well-known member
#26
Code:
<xen:if is="{$xenOptions.position} == '1'">
    Position 1
</xen:if>
Simple as that. One TM for each position.
Sorry I don't understand.

I can't create a generic Option ID as they all need to be unique. Remember I have many sidebar add-ons and each one would have an Option to select the position I want them to show in the sidebar.
 

Chris D

XenForo developer
Staff member
#27
I'm saying for each add-on, at each position, you are going to need to create a template modification that injects code into that position for that add-on.
 

cclaerhout

Well-known member
#28
Use something like this (the code can be improved using a generic template with the include template helper to repeat the foreach loop):
Code:
<xen:if is="{$myWidgetPos_1}">
   <xen:foreach loop="$myWidgetPos_1" value="$templateObject">
     <div class="widget_pos_wrapper pos_1">
       {xen:raw $templateObject}
     </div>
   </xen:foreach>
</xen:if>
<xen:if is="{$myWidgetPos_2}">
   <xen:foreach loop="$myWidgetPos_2" value="$templateObject">
     <div class="widget_pos_wrapper pos_2">
       {xen:raw $templateObject}
     </div>
   </xen:foreach>
</xen:if>
<xen:if is="{$myWidgetPos_3}">
   <xen:foreach loop="$myWidgetPos_3" value="$templateObject">
     <div class="widget_pos_wrapper pos_3">
       {xen:raw $templateObject}
     </div>
   </xen:foreach>
</xen:if>
You just need to inject some template objects (using may be the template create listener or setting it in the view controller). According to their position (can be based on an option), they will be added to the array $myWidgetPos_1, $myWidgetPos_2 or $myWidgetPos_3. Then the template will proceed to their display.

It's far to be a final code, but it gives you an approach to manage your code.