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

Custom field value in template

Discussion in 'XenForo Development Discussions' started by Will, Nov 16, 2011.

  1. Will

    Will Active Member

    I want to pull a custom field value in a template. What could I use to achieve this?
  2. Will

    Will Active Member

    Anyone have an idea about this. Hopefully what I said made sense.
  3. dmnkhhn

    dmnkhhn Active Member

    There is a template viewHelper (see Core.php, inside the ViewHelper directory, for the syntac) that you can use to show the value in a template. :)
  4. Will

    Will Active Member

    Thanks for that.

    Do you know how I can pull a value from a specific field?
  5. dmnkhhn

    dmnkhhn Active Member

    The userfieldvalue viewHelper asks for the field_id and the $user.

    The syntax should be either this:
    {xen:helper userFieldValue, 'yourfieldid', $user}
    {xen:helper userFieldValue, yourfieldid, $user}

    XenForo uses this ViewHelper in the template "message_user_info".
  6. Will

    Will Active Member

    Can't seem to get this to work.

    For example, I have this code in the template but I want to pull the value from the field to replace a space in the code.
  7. dmnkhhn

    dmnkhhn Active Member

    I am really sorry, I replied without having a working XenForo installation to verify my instructions.

    Maybe a developer can comment on this? From what I see, the above snippet should work. :)
    Will likes this.
  8. mrGTB

    mrGTB Well-Known Member

    Will likes this.
  9. Will

    Will Active Member

    Thanks, that helped me figure it out.

    Don't worry about it man. Thanks for your time.

Share This Page