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

Reply
 
Thread Tools Display Modes
  #1  
Old 02-04-2011, 10:10 PM
Majidm Majidm is offline
 
Join Date: Aug 2005
Posts: 59
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Accessing notifications on an external forum page

Here is my set up...

1) I have a header.php and footer.php file outside of vBulletin that defines the style of my entire site

2) I include these files into vBulletin via a custom plugin hooked into global_start:
PHP Code:
global $headerinclude;
ob_start(); 
require (
'/web/includes/header.php'); 
$headerinclude ob_get_contents(); 
ob_end_clean();

global 
$footerinclude;
ob_start(); 
require (
'/web/includes/footer.php'); 
$footerinclude ob_get_contents(); 
ob_end_clean(); 

Same for footer, this lets me reference my header.php file (which has a lot of custom PHP code in it) inside a vBulletin template using: $headerinclude and footer with $footerinclude

3) To make pages outside of vBulletin that can access it's resources, I do something like this:
PHP Code:
require_once("include_top.php"); //this file references forums/global.php and other files that let me access vBulletin resources
include "includes/header.php";
*
page code here*
include 
"includes/footer.php"
This lets me reference variables from vBulletin like $vbulletin->userinfo etc in my forum-external page

4) Everything works fine, I figured out that the array is called $notifications.. if I do a var_dump($notifications) in my header.php file and load my external page I get:
PHP Code:
array(11) { ["pmunread"]=> array(4) { ["phrase"]=> string(23"Unread Private Messages" ["link"]=> string(11"private.php" ["order"]=> int(10) ["total"]=> string(3"438" } ["vmunreadcount"]=> array(4) { ["phrase"]=> string(23"Unread Visitor Messages" ["link"]=> string(40"member.php?u=2&tab=visitor_messaging" ["order"]=> int(20) ["total"]=> int(0) } ["vmmoderatedcount"]=> array(4) { ["phrase"]=> string(27"Unapproved Visitor Messages" ["link"]=> string(40"member.php?u=2&tab=visitor_messaging" ["order"]=> int(30) ["total"]=> int(0) } ["friendreqcount"]=> array(4) { ["phrase"]=> string(24"Incoming Friend Requests" ["link"]=> string(28"profile.php?do=buddylist#irc" ["order"]=> int(40) ["total"]=> int(0) } ["socgroupreqcount"]=> array(4) { ["phrase"]=> string(27"Social Groups Join Requests" ["link"]=> string(21"group.php?do=requests" ["order"]=> int(50) ["total"]=> int(0) } ["socgroupinvitecount"]=> array(4) { ["phrase"]=> string(24"Social Group Invitations" ["link"]=> string(24"group.php?do=invitations" ["order"]=> int(60) ["total"]=> int(0) } ["pcunreadcount"]=> array(4) { ["phrase"]=> string(23"Unread Picture Comments" ["link"]=> string(19"album.php?do=unread" ["order"]=> int(70) ["total"]=> int(0) } ["pcmoderatedcount"]=> array(4) { ["phrase"]=> string(34"Picture Comments Awaiting Approval" ["link"]=> string(22"album.php?do=moderated" ["order"]=> int(80) ["total"]=> int(0) } ["gmmoderatedcount"]=> array(4) { ["phrase"]=> string(25"Unapproved Group Messages" ["link"]=> string(25"group.php?do=moderatedgms" ["order"]=> int(90) ["total"]=> int(0) } ["dbtech_usertag_mentioncount"]=> array(4) { ["phrase"]=> string(12"New Mentions" ["link"]=> string(31"member.php?u=2&tab=mentions" ["order"]=> int(110) ["total"]=> int(0) } ["dbtech_usertag_tagcount"]=> &array(4) { ["phrase"]=> string(15"New Thread Tags" ["link"]=> string(31"member.php?u=2&tab=usertags" ["order"]=> int(110) ["total"]=> int(0) } } 
The problem is when I go into the Forums (which loads the same header file) I just get a NULL value for the $notifications array

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

I think the problem is that the global_start hook code is called before the $notifications array is created. Maybe try a hook location that's called later on global.php, like global_setup_complete.
Reply With Quote
  #3  
Old 02-05-2011, 02:17 PM
Majidm Majidm is offline
 
Join Date: Aug 2005
Posts: 59
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
I think the problem is that the global_start hook code is called before the $notifications array is created. Maybe try a hook location that's called later on global.php, like global_setup_complete.
Thanks for the suggestion, unfortunately when I do that my header & footer do not get parsed before the forum loads so therefor my customize HTML/PHP doesn't get loaded in the forums

Seems like the reasoning is on the right track though... just gotta figure out how to parse it in the right location
Reply With Quote
  #4  
Old 02-05-2011, 02:30 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Oh, right...should have thought of that. Unfortunately there's no hook between creating the notifications array and evaling the header and footer. But the html for the header and footer is stored in $header and $footer, so maybe you can modify that after the fact (like put in place holders and do a str_replace on them later).
Reply With Quote
  #5  
Old 02-06-2011, 01:39 AM
Majidm Majidm is offline
 
Join Date: Aug 2005
Posts: 59
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Not sure what you mean, can you give me an example?
Reply With Quote
  #6  
Old 02-06-2011, 01:36 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Sorry - yeah, I might be wrong. After reading your OP I should have asked, what template are you putting $headerinclude and $footerinclude in? I guess I was assuming that it was the header, navbar, and/or footer templates.

ETA: ...but assuming I guessed right and you are using the "header" and "footer" templates, what I was suggesting is that instead of inserting $headerinclude and $footerinclude in the templates, change it to something like <!-- Custom Header -->, etc. Then move your plugin to global_setup_complete (where the header and footer templates will have already been processed and the $notifications array created), and add this to the end of your plugin code:

Code:
$header = str_replace('<!-- Custom Header -->', $headerinclude, $header);
$footer = str_replace('<!-- Custom Footer -->', $footerinclude, $footer);

Also, I think the way you have things set up, on your custom pages your header and footer php files will be read in the plugin and then again in your page code, so for efficiency you could surround the plugin code by an "if" statement that checks THIS_SCRIPT and doesn't do the include if it's your custom script.

(BTW, I haven't tried this code).
Reply With Quote
  #7  
Old 02-06-2011, 02:52 PM
Majidm Majidm is offline
 
Join Date: Aug 2005
Posts: 59
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
Sorry - yeah, I might be wrong. After reading your OP I should have asked, what template are you putting $headerinclude and $footerinclude in? I guess I was assuming that it was the header, navbar, and/or footer templates.

ETA: ...but assuming I guessed right and you are using the "header" and "footer" templates, what I was suggesting is that instead of inserting $headerinclude and $footerinclude in the templates, change it to something like <!-- Custom Header -->, etc. Then move your plugin to global_setup_complete (where the header and footer templates will have already been processed and the $notifications array created), and add this to the end of your plugin code:

Code:
$header = str_replace('<!-- Custom Header -->', $headerinclude, $header);
$footer = str_replace('<!-- Custom Footer -->', $footerinclude, $footer);

Also, I think the way you have things set up, on your custom pages your header and footer php files will be read in the plugin and then again in your page code, so for efficiency you could surround the plugin code by an "if" statement that checks THIS_SCRIPT and doesn't do the include if it's your custom script.

(BTW, I haven't tried this code).
Yes I'm putting $headerinclude in the header template, and $footerinclude in the footer template.. I will try your suggestion, thank you

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

Quote:
Originally Posted by Majidm View Post
Yes I'm putting $headerinclude in the header template, and $footerinclude in the footer template.. I will try your suggestion, thank you
It worked!!! Thank you so much
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 09:42 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.11104 seconds
  • Memory Usage 2,264KB
  • 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
  • (2)bbcode_code
  • (3)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete