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

Reply
 
Thread Tools Display Modes
  #1  
Old 04-11-2012, 08:10 PM
Cadellin's Avatar
Cadellin Cadellin is offline
 
Join Date: Jan 2009
Posts: 160
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default notifications_total in FORUMHOME

I'm trying to display $notifications_total in the FORUMHOME template ({vb:raw notifications_total} but without success whereas the same variable works fine elsewhere.

I assume my issue is that $notifications_total isn't a global variable in which case what can I do?

Thanks for any assistance.
Reply With Quote
  #2  
Old 04-11-2012, 08:15 PM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try:

Code:
{vb:raw notifications_total}
Reply With Quote
  #3  
Old 04-11-2012, 08:33 PM
Cadellin's Avatar
Cadellin Cadellin is offline
 
Join Date: Jan 2009
Posts: 160
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks Boofo but I've tried that. Typo in the top post.
Reply With Quote
  #4  
Old 04-11-2012, 08:50 PM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The it must not be available on the forumhome. You might need to do a query for it.
Reply With Quote
  #5  
Old 04-11-2012, 09:23 PM
Cadellin's Avatar
Cadellin Cadellin is offline
 
Join Date: Jan 2009
Posts: 160
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I've come up with the below which works on FORUMHOME and SHOWTHREAD.

I want to use this in a lot of templates so would it be better to make it a global variable (if that's possible) or should I just create a long list of preRegisters?

PHP Code:
$currentuserid $vbulletin->userinfo[userid];

$query "SELECT * FROM prefix_user WHERE userid = $currentuserid";
$result $db->query($query);

while(
$row $db->fetch_array($result)) {

    
$a $row['friendreqcount'];
    
$b $row['vmunreadcount'];
    
$c $row['socgroupinvitecount'];
    
$d $row['socgroupreqcount'];
    
$e $row['pcunreadcount'];
    
$f $row['vbseo_likes_unread'];
    
$h $row['pmunread'];
}

$title_note_count $a $b $c $d $e $f $h;

vB_Template::preRegister('FORUMHOME',array('title_note_count' => $title_note_count));
vB_Template::preRegister('SHOWTHREAD',array('title_note_count' => $title_note_count)); 
Thanks for your help!
Reply With Quote
  #6  
Old 04-11-2012, 09:56 PM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Where are you trying to use this?
Reply With Quote
  #7  
Old 04-12-2012, 07:34 AM
Cadellin's Avatar
Cadellin Cadellin is offline
 
Join Date: Jan 2009
Posts: 160
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm trying to get the total number of notifications into the page title in a similar way to Twitter or Facebook. E.g. "(4) vBulletin.org Forum".
Reply With Quote
  #8  
Old 04-12-2012, 07:51 AM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I don't use Twitter or Facebook so I have no idea how they do things. Where are you wanting this to show up exactly?
Reply With Quote
  #9  
Old 04-12-2012, 08:20 AM
Cadellin's Avatar
Cadellin Cadellin is offline
 
Join Date: Jan 2009
Posts: 160
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Sorry I'll try to explain better.

I want to add the total number of notifications to HTML page title. Like this:

So in the template something like this (variables are from memory):
HTML Code:
<title>({vb:raw notifications_total}) {vb:raw bboptions:title}</title>
The result of which would be something like this:



Thanks
Attached Images
File Type: jpg demo.JPG (11.3 KB, 0 views)
Reply With Quote
  #10  
Old 04-12-2012, 11:57 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I don't think you need to do a query because the global $notifications_total should contain the total (assuming it's been calculated at the point you're trying to use it, of course), but it has to be registered to the template(s) where you want to use it. If you create a plugin using hook process_templates_complete you should be able to do preRegisters there. (process_templates_complete was just added a couple versions ago so it's possible you don't have it if you're not up to date).

You would have to register it to each template as I don't think there's any way to globally register to all templates. But there is a number of globals that *are* registered automatically in each template, so you could piggy back on one of those. For instance, $vbulletin->userinfo is registered as bbuserinfo, so in your plugin you could set $vbulletin->userinfo['notifications_total'] = $notifications_total then use {vb:raw bbuserinfo.notifications_total} in each template. (Probably some people will tell you that you shouldn't really do it this way, but I don't see a problem with it).
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 04:19 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04389 seconds
  • Memory Usage 2,278KB
  • Queries Executed 12 (?)
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
  • (1)bbcode_code
  • (1)bbcode_html
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)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
  • (1)postbit_attachment
  • (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
  • postbit_attachment
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete