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

XF 1.5 How to pass a variable in a phrase in postbit?

Discussion in 'Styling and Customization Questions' started by Neutral Singh, Feb 14, 2016.

  1. Neutral Singh

    Neutral Singh Well-Known Member

    How can i pass a variable in a phrase in the postbit? So, that along with every post, the name of the poster can be shown as shown in the image.

    For example: Phrase abc has value "Start a Conversation with {username}", here what would the xenforo variable to be passed in the phrase...

    i hope i made some sense... :rolleyes:
    conversation.jpg
     
  2. Brogan

    Brogan XenForo Moderator Staff Member

  3. Neutral Singh

    Neutral Singh Well-Known Member

    Sorry, i have no clue how to implement it... i am no programmer... o_O
     
  4. Robust

    Robust Well-Known Member

    What Brogan linked isn't really programming. It kinda answers your question, I can't really even add to that. That's how to use variables in templates.
     
  5. Brogan

    Brogan XenForo Moderator Staff Member

    Essentially you just edit the appropriate template (see this guide for how to determine that: https://xenforo.com/community/resources/how-to.4390/) and in its most basic form, you would add this, wrapped in an appropriate a tag:
    Code:
    Start a conversation with {$user.username}
     
    Neutral Singh likes this.
  6. Neutral Singh

    Neutral Singh Well-Known Member

    Thanks @Brogan

    Actually, i had already figured it out that it would be {$user.username} but i was wondering if i could put it in a phrase... which i was asking in the first post... but it was returning {$user.username} as it is.

    Actually, it was a template modification and i had to put {$user.username} in there to be able to make it work and now it works!
     
  7. Robust

    Robust Well-Known Member

    {xen:phrase 'phrase_name', 'variable={$value}'}

    phrase_name:
    This is {variable}
     
    Neutral Singh likes this.

Share This Page