• 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


Formerly MtoR

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:
<xf:macro template="my_template" name="my_name" arg-name="toto">
    <input type="hidden" name="{$name}_myfield" value="{$node.some_index.{$name}_myfield}" />
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,


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