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

XF 1.2 Creating and Associating Phrases

Discussion in 'XenForo Questions and Support' started by Amaury, Feb 13, 2014.

  1. Amaury

    Amaury Well-Known Member

    I have a suggestion thread here regarding adding more phrases, but rather than waiting for it to be implemented or not, I thought I'd try myself.

    So, using watched threads as an example, the "Managing account details" phrase is currently used for your activity when you're on that page, but that really only makes sense for stuff related to managing your account, such as your personal details (although I would like to get specific with each of the things relating to your account as well, such as "Managing signature").

    Anyway, I know where to create phrases, so I would go there and create a phrase with "Viewing watched threads" as the text, but how do I associate it? If I were to go to my watched threads, I'd still see "Managing account details."

    Also, how would I create and associate a phrase containing a hyperlink? For example, "Viewing likes received."

    Thanks!
     
  2. Brogan

    Brogan XenForo Moderator Staff Member

    Once you have created a phrase you need to call it in a template.

    If you want to change existing wording, edit the original phrase.
     
    Amaury likes this.
  3. Amaury

    Amaury Well-Known Member

    I edited in another example in regards to hyperlinks.

    Yeah, for currently existing phrases, it's a simple as just editing the phrases (e.g., Viewing forum list > Viewing something). However, to create new ones and associate them, not so much.

    Okay, so I need to call them in templates. I'm assuming I would edit the corresponding templates? For example, for watched threads, I would edit the watch_threads template? What code would I place in there to call my phrase? Would it be this code?

    Code:
    {xen:phrase show_all_watched_threads}
    Obviously, I would change the phrase name to whatever the phrase's name is (e.g., viewing_watched_threads), but would that be the correct code?
     
  4. Brogan

    Brogan XenForo Moderator Staff Member

    Yes, that is how you call a phrase in a template.
     
    Amaury likes this.
  5. Amaury

    Amaury Well-Known Member

    Okay, thanks. :)

    Was I also right on what template to edit? Since this would have to do with watched threads, I would place that code in the watch_threads template? And then would there be anything else I'd need to do or would just inserting that code have me good to go?
     
  6. Brogan

    Brogan XenForo Moderator Staff Member

    I don't know what you'e trying to achieve exactly.

    The phrase needs to be added to the template for the page you want it to show on.
    It also needs to be added in the correct location, depending on where you want it to show.
    Additional styling may be required to make it appear exactly how you want.
     
  7. Amaury

    Amaury Well-Known Member

    To give you an example, when I'm on the watched threads page and look at my profile or member card, the activity phrase used is "Managing account details." I want to achieve adding and associating a new phrase specifically for watched threads so the activity phrase is more specific, which would be "Viewing watched threads," something vBulletin has in the core, except the phrase is "Viewing Subscribed Threads."

    [​IMG]

    I would also like to do this with a lot of other areas, such as watched forums, which I won't need help on because I can just use the watched threads one as an example to follow.

    That's exactly what I'm asking. In this case, the template for the watched threads page would be watch_threads, correct?

    How do you tell what the correct location is? xD

    You mean like text color? All I want to do is add a phrase, not style something.

    To put this in simpler terms, when you created your Featured Threads add-on, you created the phrase "Viewing features threads" to avoid "Viewing unknown page" when on the Featured Threads page. My case is the same pretty much, I'm just not fixing an unknown location. I want to create and associate a new phrase called "Viewing watched threads" that'll show as your activity when on the watched threads page.

    Hope I explained myself better, and thanks for the help! :)
     
  8. Brogan

    Brogan XenForo Moderator Staff Member

    You can't do that with a simple phrase.
    It requires php.
     
    Amaury likes this.
  9. Amaury

    Amaury Well-Known Member

    Unfortunately, all I know about PHP is this: PHP. (Sound familiar? :p)

    If you don't mind my asking, what did you think I was asking? Because before you said all I had to do was create and call the phrase.
     
  10. Amaury

    Amaury Well-Known Member

    @Brogan

    I'm an idiot. I just realized I know some very basic PHP from fixing unknown locations back when we were on vBulletin, but that's really all I know. (See an example here.) However, either I'm missing something or there's no plugin manager in XenForo to create plugins with PHP code, so how would I accomplish what I want to do?

    Also, and I don't believe this one would require PHP, I'd like to add "Current Style:" to the left of the style name in the footer. To get started, I would create a new phrase called "Current Style," but in which template and what part of said template do I place the callback code?

    Footer.png
     
  11. Amaury

    Amaury Well-Known Member

    Anyone? :)
     
  12. Brogan

    Brogan XenForo Moderator Staff Member

    Edit the footer template - look for <dt>{xen:phrase style}</dt>.
     
    Amaury likes this.
  13. Amaury

    Amaury Well-Known Member

    Thank you very much, Brogan.

    How about the PHP one? Like I said, I know very basic PHP knowledge; however, is it essentially like creating a plugin on vBulletin or is it a bit more complicated? Alternatively, it might be better for me to just edit my suggestion regarding adding more phrases and see if XenForo adds them. :)
     
  14. Brogan

    Brogan XenForo Moderator Staff Member

    I'm not sure what the php related question is now.
    If it's related to "Viewing x page", then that would require some programming knowledge.
     
    Amaury likes this.
  15. Amaury

    Amaury Well-Known Member

    Correct. On vBulletin, to fix unknown locations you'd just do this. Is that what you did to deal with the unknown location of your Featured Threads add-on?

    However, like on vBulletin, I think creating activity locations for areas that are already associated with other activity locations is what's tough. For example, as I've said before, when you're on http://xenforo.com/community/watched/threads, it already uses "Managing account details" for the activity location and changing it to "Viewing/Managing watched threads" would require quite a bit of PHP knowledge, as you've said.

    So I think I'll just give up on that for now if it's that complicated and just work on the suggestion when I get around to it. :)
     
  16. Amaury

    Amaury Well-Known Member

    Okay, so I found that, but what do I do with it? I don't see "Style" being displayed anywhere, either.
     
  17. Brogan

    Brogan XenForo Moderator Staff Member

    As an example, change this:
    {$visitorStyle.title}</a>

    To this:
    Current Style: {$visitorStyle.title}</a>

    There are various ways you can achieve what you want, that's one of them.
    Experiment by editing the templates/phrases.
     
    Amaury likes this.
  18. Amaury

    Amaury Well-Known Member

    With that method, it doesn't look like I even need to create a phrase. However, if I did do the create a phrase method, this would be correct, right?

    Code:
    {xen:phrase current_style} {$visitorStyle.title}
    In any case, thanks for the help, Brogan! (y)
     
  19. Brogan

    Brogan XenForo Moderator Staff Member

    Yes, you could phrase it.
    If you decide to ever create any phrases or templates of your own, my advice is to prefix them, to avoid potential clashes.
    All of my custom phrases, templates, CSS classes, etc. all begin with "cta".
     
    Amaury likes this.
  20. Amaury

    Amaury Well-Known Member

    Good advice! (y) I think I'll do it exactly like that: khf_current_style.

    Edit: And I'm definitely going to rename our custom templates, like the Staff Team page, now.
     

Share This Page