vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=251)
-   -   displaying a variable from the database (https://vborg.vbsupport.ru/showthread.php?t=281986)

ohadpartuck 04-24-2012 02:44 PM

displaying a variable from the database
 
Hi,
I have a php script that runs on a page that is called chat.php.
It counts the current active users and save that to the database.

I want to display that number on the navigation bar in next to the chat link.
How do I do that?
I have read this article that saves an adittional field and displays it but that was when an article loads.
how do I make it for the navbar loading?:)

kh99 04-24-2012 03:28 PM

You want to display it on the navbar on all pages (not just your chat page)? Then you need to create a plugin that queries the database for that value, then registers it to the navbar template. Then you can edit the navbar template and insert that value where you want it. Something like:

Code:

$chatters = $vbulletin->db->query_first("SELECT chatters FROM some_table");
vB_Template::preRegister('navbar', array('chatters' => $chatters['chatters']));


then in the navabr template

Code:

{vb:raw chatters}

The hook choice is a little tricky (or maybe someone else knows better), but you'd ideally not want to add the query unless it's needed, but since the navbar is rendered in a bunch of separate scripts there doesn't seem to be any way to know for sure when it's needed. In any case global_setup_complete should work.

Boofo 04-24-2012 03:53 PM

The preRegister line should be this:

Code:

vB_Template::preRegister('navbar', array('chatters' => $chatters));

ohadpartuck 04-25-2012 09:07 AM

thanks boofo, but kh99 was right because the sql query returns an array.

It works partially. I can disaply the chatters on the page, but not where I want it.

Let's say I wnat to add a new link to the chat page in the navigation bar called "Chat" (the one I have now is via DBTech - vBNavTabs so that cant work (I've tried)).

I've tried to add in various locations in the 'navbar' Template :
<li><a href="mycahatlink" class="navtab">My chat Tab</a></li>

But it's not adding!!! dammit!

please help me with this one..

Boofo 04-25-2012 09:22 AM

Okay, I see how he did it. By doing it his way, you can skip a few steps in setting it up.

ohadpartuck 04-25-2012 10:13 AM

does anyone know a good solution for the other problem that I wrote?

Boofo 04-25-2012 10:30 AM

Lynne did an article on adding Tabs a while back. You might want to check it out in the Articles area.


All times are GMT. The time now is 02:17 AM.

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.01036 seconds
  • Memory Usage 1,720KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete