Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 08-02-2012, 05:34 PM
thedukeboard thedukeboard is offline
 
Join Date: Jul 2012
Posts: 15
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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.
Reply With Quote
  #2  
Old 08-02-2012, 05:51 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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);
Reply With Quote
  #3  
Old 08-02-2012, 07:30 PM
thedukeboard thedukeboard is offline
 
Join Date: Jul 2012
Posts: 15
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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));
Then adding this link in to the navbar manually:

Code:
<li><a href="/chat/">Chat ({vb:raw num_chatting})</a></li>
It wouldn't position itself properly in the submenu like I'd like but it did display the correct amount of users chatting as I want it. Any idea how to amend that plugin or where I can manually add the link in 4.2?

Thanks again for taking the time.
Reply With Quote
  #4  
Old 08-02-2012, 07:39 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #5  
Old 08-02-2012, 10:22 PM
thedukeboard thedukeboard is offline
 
Join Date: Jul 2012
Posts: 15
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Code:
$identity = 'link_mzg2_354'; // change this to "Identity" of tab or link
$num_chatting = 5; // obviously you'll need to set this
Link displays but nothing showing users in chat.

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.
Reply With Quote
  #6  
Old 08-02-2012, 10:36 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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)";
}
Reply With Quote
2 благодарности(ей) от:
Deathjam, thedukeboard
  #7  
Old 08-02-2012, 10:43 PM
thedukeboard thedukeboard is offline
 
Join Date: Jul 2012
Posts: 15
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It worked! Thanks sooooo much.
Reply With Quote
  #8  
Old 04-07-2013, 07:47 PM
vBNinja's Avatar
vBNinja vBNinja is offline
 
Join Date: May 2011
Location: USA
Posts: 239
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
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)";
}

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!
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:49 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03909 seconds
  • Memory Usage 2,235KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (6)bbcode_code
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (8)post_thanks_box
  • (2)post_thanks_box_bit
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete