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

xenOption as FieldID?

nrep

Well-known member
#1
I've got a modification coded, however I'm having problems with getting the a field name set in the options menu to work as part of a xen:string display.

I've got an option set ({$xenOptions.specfieldid}) which I'd like to use in the xen:string code below:

{xen:string nl2br, $user.customFields.{$xenOptions.specfieldid}}

However, I can't nest things like that and get a parse error.

Is there a way I can do this? Effectively, I'm specifying a field name in options and I'd like to be able to display it using the {xen:string} code.
 

Jeremy

Well-known member
#2
You won't be able to do this in templates. You will need to write an add-on to extend the actions necessary to insert that value into a separate variable.
 

nrep

Well-known member
#3
Thanks for the reply - although your answer is what I feared! I was hoping there would be a workaround using "xen:set var" or something.

Is there a way I can rename custom userfield IDs instead?
 

Chris D

XenForo developer
Staff member
#4
Try:

{xen:string nl2br, '{$user.customFields.{$xenOptions.specfieldid}}'}

Long shot but often the single quote marks help the template process what you're trying to do a bit easier.

Also xen:set var should work if my example above doesn't.