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

xenOption as FieldID?

Discussion in 'XenForo Development Discussions' started by nrep, Aug 3, 2013.

  1. nrep

    nrep Well-Known Member

    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.
     
  2. Jeremy

    Jeremy XenForo Moderator Staff Member

    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 likes this.
  3. nrep

    nrep Well-Known Member

    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?
     
  4. Chris D

    Chris D XenForo Developer Staff Member

    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.
     
    Jeremy and nrep like this.
  5. nrep

    nrep Well-Known Member

    Fantastic! That did the trick Chris :).
     
    Chris D likes this.

Share This Page