The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Put phrase in navbar link title
Hi, I'd really appreciate someone helping me know how to put a phrase in the link title of a navbar/submenu link. Every time I do it the phrase ({vb:raw num_chatting}) just appears as plain text instead of showing up as I'd like it.
I'm using 4.2 Thanks in advance. |
#2
|
|||
|
|||
You can't put in anything other than text. If you wanted to provide translations what you could do is find the phrases that are created for each tab or link then enter the translations there.
But it looks like what you want is for the text to be "dynamic" so you can have it display the current number of people in chat? To do that you could create a plugin using hook build_navigation_data and override the text for a tab or link, like: Code:
$identity = 'link_abc5_abc'; // change this to "Identity" of tab or link $num_chatting = 5; // obviously you'll need to set this $navdata[$identity]['text'] = $num_chatting; // or if you want to use a phrase, do something like this instead: $navdata[$identity]['text'] = construct_phrase($vbphrase['num_chatting'], $num_chatting); |
#3
|
|||
|
|||
Thanks for the reply. I tried making that plugin but it just made the link disappear.
Here is the plugin I was originally using: Code:
$result = mysql_query("SELECT * FROM ajax_chat_online"); $num_chatting = mysql_num_rows($result); vB_Template::preRegister('navbar',array('num_chatting' => $num_chatting)); vB_Template::preRegister('FORUMHOME',array('num_chatting' => $num_chatting)); Code:
<li><a href="/chat/">Chat ({vb:raw num_chatting})</a></li> Thanks again for taking the time. |
#4
|
|||
|
|||
Hmm...if your link disappeared then you must have been on the right track. I'd have to see exactly what code you used (did you maybe leave the last line there without actually having created a phrase?).
Sorry, I don't know how you'd go about adding it manually. |
#5
|
|||
|
|||
Code:
$identity = 'link_mzg2_354'; // change this to "Identity" of tab or link $num_chatting = 5; // obviously you'll need to set this Ideally I'd like it to appear as Chat (1) [1 being the number of users currently in], pulling the ajax data I posted above. I'm new to this. |
#6
|
|||
|
|||
OK, maybe your plugin code could be this (using hook build_navigation_data - and you can disable the other plugin):
Code:
if (is_array($navdata['link_mzg2_354'])) { $result = mysql_query("SELECT * FROM ajax_chat_online"); $num_chatting = mysql_num_rows($result); $navdata['link_mzg2_354']['text'] = "Chat ($num_chatting)"; } |
2 благодарности(ей) от: | ||
Deathjam, thedukeboard |
#7
|
|||
|
|||
It worked! Thanks sooooo much.
|
#8
|
||||
|
||||
Quote:
I'm trying to do the same thing but im using 4.1.10 and it doesn't have that hook, is there another way I can do it? Thanks! |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|