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

{$user.$fieldId} in Template?

Discussion in 'XenForo Development Discussions' started by Jake B., Jan 27, 2015.

  1. Jake B.

    Jake B. Well-Known Member

    So, I'm looping through some values in the 'message_user_info' template and need to display userinfo based on the ID I have in a variable. I need to replicate something like '$user[$fieldId]' in a template. I've tried using $user.fieldId but it didn't work. I know I can go through the values by extending a view and adding the values that way, but I'd rather not have to do that for every view that uses the 'message' template so it'll be compatible with any other add-ons using the 'message' template that may be installed on the same board.
     
  2. Jeremy

    Jeremy XenForo Moderator Staff Member

    If $fieldId is another variable, you should can accomplish it with:
    {$user.{$fieldId}}

    Here's an example in use in the Resource Manager:
    Code:
    {$fileParams.{$uploaderId}.hash}
     
    Jake B. likes this.
  3. Jake B.

    Jake B. Well-Known Member

    I had tried that, but it was in a helper and I wasn't using curly braces because I wasn't using it in a string, I'll try it that way though.
     
  4. Jeremy

    Jeremy XenForo Moderator Staff Member

    If that doesn't work, some example code is necessary.
     
    Jake B. likes this.
  5. Jake B.

    Jake B. Well-Known Member

    It worked perfectly, thanks!
     

Share This Page