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

Reply
 
Thread Tools Display Modes
  #11  
Old 08-31-2011, 06:50 PM
ICThawk ICThawk is offline
 
Join Date: Feb 2011
Posts: 17
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
It looks like you've misspelled 'navbar' in your preregister call.
Good catch. Sadly with that fixed it still doesn't work. Ideas?
Reply With Quote
  #12  
Old 08-31-2011, 07:14 PM
nima6's Avatar
nima6 nima6 is offline
 
Join Date: Jan 2007
Posts: 68
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It is official. I am an idiot. I had a spelling error as well
Reply With Quote
  #13  
Old 08-31-2011, 07:41 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by ICThawk View Post
Good catch. Sadly with that fixed it still doesn't work. Ideas?
Which hook are you using? Try using parse_templates if you aren't already.
Reply With Quote
  #14  
Old 09-01-2011, 12:16 AM
ICThawk ICThawk is offline
 
Join Date: Feb 2011
Posts: 17
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
Which hook are you using? Try using parse_templates if you aren't already.
I don't know what parse templates are.

I used the hook global_start. execution order 5.

Does the PHP code need to be contained in <?php tags?

Here is the code in my php file in case it matters.

PHP Code:
<?php

require_once('./global.php');

// Query the database and get the count 
$result mysql_query("SELECT * FROM ajax_chat_online"); 
$num_rows mysql_num_rows($result); 

// Display the results 
echo $num_rows


?>
Reply With Quote
  #15  
Old 09-01-2011, 04:39 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You don't need the <?php in plugin code.

'parse_templates' is a different hook location, but 'global_start' will work so you're OK.

I think you had another typo in the code you posted above (there's an extra space in 'includedphp ', which I now see is a typo in the "Rendering Templates..." article).

Try this:

PHP Code:
ob_start();
  include(
'/home/bluepr12/public_html/wavingthewheat.com/chatuser.php');
  
$includedphp ob_get_contents();
ob_end_clean();

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



BTW, not to confuse things further, but you could also do something like this in the plugin:

PHP Code:
$result mysql_query("SELECT * FROM ajax_chat_online");  
$num_chatting mysql_num_rows($result);  
vB_Template::preRegister('navbar',array('num_chatting' => $num_chatting)); 

and {vb:raw num_chatting} in the template, and you wouldn't need the external file.
Reply With Quote
  #16  
Old 09-01-2011, 01:55 PM
ICThawk ICThawk is offline
 
Join Date: Feb 2011
Posts: 17
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

kh99 thanks a ton for your help. I decided to go with your last option and have the plugin execute the php.

I have a couple more questions though.

1.) What hook do I need to use so that this will display on the front page. It works on the forum, but not on the CMS.

2.) I would like to list who is online on the forum home. In that ajax_chat_online table each online user is stored in a row. I would like to display the column userName for all entries separated by a comma. Any thoughts?

Again, thank you very much for all your help so far!
Reply With Quote
  #17  
Old 09-01-2011, 02:23 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by ICThawk View Post
1.) What hook do I need to use so that this will display on the front page. It works on the forum, but not on the CMS.
Try global_bootstrap_init_start

Quote:
2.) I would like to list who is online on the forum home. In that ajax_chat_online table each online user is stored in a row. I would like to display the column userName for all entries separated by a comma. Any thoughts?
PHP Code:
global $vbulletin;

$results $vbulletin->db->query_read_slave("SELECT userName FROM ajax_chat_online");
while (
$row $vbulletin->db->fetch_array($results))
    
$chat_userlist[] = $row['userName'];
$chat_userlist implode(','$chat_userlist);
$vbulletin->db->free_result($results);
vB_Template::preRegister('navbar', array('chat_userlist' => $chat_userlist)); 

Obviously, if you're using the same plugin as you are for the count you could combine both so you're not doing two queries.
Reply With Quote
  #18  
Old 09-01-2011, 02:51 PM
ICThawk ICThawk is offline
 
Join Date: Feb 2011
Posts: 17
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks! You had a typo but I caught it. Thanks for all of your help!!

--------------- Added [DATE]1314893620[/DATE] at [TIME]1314893620[/TIME] ---------------

Man you have no idea how helpful you have been. With your help I have put together the following Mod Thread https://vborg.vbsupport.ru/showthread.php?p=2240829 to help everyone else who is in the same boat as me.

--------------- Added [DATE]1314962655[/DATE] at [TIME]1314962655[/TIME] ---------------

Well I have found one hiccup. With the second plugin. The one that displays the userNames.

If no one is in the chat and the code returns a NULL result then it breaks the site. Gives me a cookie in header already sent error. Thoughts??
Reply With Quote
  #19  
Old 09-02-2011, 06:08 PM
ICThawk ICThawk is offline
 
Join Date: Feb 2011
Posts: 17
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Bump
Reply With Quote
  #20  
Old 09-02-2011, 06:19 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Sorry, I always seem to miss when posts get auto-merged.

Anyway, yeah, didn't think of that. You want something like this:

PHP Code:
global $vbulletin

$results $vbulletin->db->query_read_slave("SELECT userName FROM ajax_chat_online"); 
while (
$row $vbulletin->db->fetch_array($results)) 
    
$chat_userlist[] = $row['userName']; 
if (
is_array($chat_userlist))
{
    
$chat_userlist implode(','$chat_userlist); 
    
$vbulletin->db->free_result($results); 
}
else
{
    
// set $chat_userlist to a "no one chatting" message if you want, or leave blank.
    
$chat_userlist '';
}
vB_Template::preRegister('navbar', array('chat_userlist' => $chat_userlist)); 
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 03:53 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.04201 seconds
  • Memory Usage 2,277KB
  • 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
  • (5)bbcode_php
  • (5)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete