XF 1.2 Creating and Associating Phrases

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!
 
I edited in another example in regards to hyperlinks.

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.

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?
 
Yes, that is how you call a phrase in a template.

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?
 
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.
 
I don't know what you'e trying to achieve exactly.

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."

nvlfkWZ.png

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.

The phrase needs to be added to the template for the page you want it to show on.

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

It also needs to be added in the correct location, depending on where you want it to show.

How do you tell what the correct location is? xD

Additional styling may be required to make it appear exactly how you want.

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! :)
 
You can't do that with a simple phrase.
It requires php.

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.
 
@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.webp
 
@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?

View attachment 67898

Anyone? :)
 
Edit the footer template - look for <dt>{xen:phrase style}</dt>.

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. :)
 
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.

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. :)
 
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.
 
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.

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)
 
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".
 
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 phrase, templates, CSS classes, etc. all begin with "cta".

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.
 
Back
Top Bottom