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

Variables in xenOptions?

Discussion in 'XenForo Development Discussions' started by Chris D, Jun 26, 2012.

  1. Chris D

    Chris D XenForo Developer Staff Member

    I am working on an add-on with configurable options in the Admin CP.

    One of the options needs to have a default value of:

    Hey {$visitor.username}!

    If I use {$xenOptions.heyUser} in my template, the output is: Hey {$visitor.username}!

    I'm looking for it to output: Hey Yorick!
     
  2. Mr. Goodie2Shoes

    Mr. Goodie2Shoes Well-Known Member

    This is bound to happen because templates are only rendered once, and it only renders {$xenOptions.heyUser} and thats why {$visitor.username} is not rendered ;)
    You have to use XenForo's 'hook' system for this...
     
  3. Robbo

    Robbo Well-Known Member

    I don't even understand the question... or the answer given... what you have written out should just work if you have that option?
     
  4. James

    James Well-Known Member

    I think I'm following.

    You've got a text-field in the Admin CP that contains this text:
    "Hey {$visitor.username}!"

    and your field ID is heyUser?

    So when you use $xenOptions.heyUser - it outputs the text field.

    The problem here is that you can't use template syntax inside the text fields - when they're placed in the templates they're treated as normal text. You'll have to use an add-on, as stated above, to achieve what you want.
     
  5. Chris D

    Chris D XenForo Developer Staff Member

    It's ok dudes. I knew the reason why it wasn't working, I was more looking for help with a practical solution. But in the end I figured it out.

    I've tested this as working. I'm going to explain in the Admin CP options to reference the visitor's username with {user} then I'm going to run a template_post_render and replace {user} with $visitor['username']

    :)

    Thank you all for the replies.
    Options:
    heyuser.PNG

    End result:
    heyuser1.PNG
     
    James likes this.

Share This Page