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

XF 2.0 Use of variable in variable name in macros

XFA

Well-known member
#1
Hi,

Not sure the title is understandable but I would like to retrieve in the code of a template macro, a variable value which name is based on an arg of the template macro.

Something like that:
Code:
<xf:macro template="my_template" name="my_name" arg-name="toto">
    <input type="hidden" name="{$name}_myfield" value="{$node.some_index.{$name}_myfield}" />
</xf:macro>
I think I already did that in xf1 and it worked but for xF2 it doesn't, any idea on how to achieve that ?

Thank you,
Clément
 

Mike

XenForo developer
Staff member
#2
Use <xf:set var="$fieldName" value="{$name}_myfield" /> and then you should be able to access {$node.some_index.{$fieldName}}