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

Basic variables like username

Discussion in 'XenForo Questions and Support' started by Morgain, Dec 5, 2011.

  1. Morgain

    Morgain Well-Known Member

    How do I make a username appear in the text on an XF html Page?
    or in the Page Title?

    Also is there a list anywhere of basic variables like that?
    I used to use one on another forum software which was very useful. I think that was $user
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

  3. Morgain

    Morgain Well-Known Member

    Jake you're a darling as always.
    I got that to work in the Page body.

    Any chance of making the user's name appear in the Page Title -
    (the large title which shows on the Page with a line of small description text underneath it)

    so it could be called XXXX's Toybox - or whatever.
  4. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Most of the "view" templates have a xen:h1 tag at the top. That is where the title is defined. You can add the username variable to that tag. For example:

    <xen:h1>{$visitor.username}'s Toybox</xen:h1>
    Morgain likes this.
  5. Morgain

    Morgain Well-Known Member

    Jake that's very satisfying.
    What if it's a visitor not logged in?
    How would I make it say "My" instead of the username?

    Also I put
    {$visitor.username}'s Toybox
    in as the Title in the admincp edit form but what appears in the node list is the code, not my name.
  6. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    It only works in templates, not in node titles. An addon is required to make this work in node titles.
  7. Morgain

    Morgain Well-Known Member

    OK thanks Jake.l Much appreciated. I'm learning steadily thanks to you and Brogan and others.

Share This Page