vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Using Variables outside vBulletin (https://vborg.vbsupport.ru/showthread.php?t=211626)

ScottC2105 04-20-2009 12:49 AM

"spot prior to the header being evaled" - Which template bit would that be?

Lynne 04-20-2009 03:02 AM

You don't put php code in templates. So, you would have to copy the code that creates $notifications_total into a plugin, or into the actual page (if you can't find a good hook location) to a spot that is prior to the header template being evaled. I believe the $notifications_total is defined in global.php, so you can copy the code from there.

ScottC2105 04-20-2009 10:43 AM

Quote:

Originally Posted by Lynne (Post 1794905)
You don't put php code in templates. So, you would have to copy the code that creates $notifications_total into a plugin, or into the actual page (if you can't find a good hook location) to a spot that is prior to the header template being evaled. I believe the $notifications_total is defined in global.php, so you can copy the code from there.

I've copied the code (not sure if I an post it here) and made ther hook global_start and it still isn't working. What am I doing wrong?

Lynne 04-20-2009 02:06 PM

In looking at global.php, you shouldn't have even had to copy the code. It looks like the header template is evaled right after the code (just a few lines later). If it isn't showing up, then there is something else going on. Either there are no notifications, or some other error is causing problems. Check your error_logs and see if anything is showing up there. Otherwise, I'm not sure what else to suggest.

ScottC2105 04-20-2009 07:26 PM

Quote:

Originally Posted by Lynne (Post 1795165)
In looking at global.php, you shouldn't have even had to copy the code. It looks like the header template is evaled right after the code (just a few lines later). If it isn't showing up, then there is something else going on. Either there are no notifications, or some other error is causing problems. Check your error_logs and see if anything is showing up there. Otherwise, I'm not sure what else to suggest.

I see what you mean, it does work. I am using the plugin system to include a custom login box .php file I have made and inserting it in the header. Now, if this file is on any other page but a vBulletin one it shows $notifications_total fine. If it is included using the plugin system into my vbulletin skin $notifications_total doesn't work in my php file but it does in the template header.

I am using global_start hook for the plugin. Am I doing something wrong?

Lynne 04-20-2009 07:32 PM

We went through a strange issue a week or so ago where plugins weren't getting parsed on external pages. The solution for that was here. I'm not sure if that would help out here cuz I never did go research exactly what was going on, but at this point it might be worth a shot.

ScottC2105 04-20-2009 08:22 PM

Quote:

Originally Posted by Lynne (Post 1795425)
We went through a strange issue a week or so ago where plugins weren't getting parsed on external pages. The solution for that was here. I'm not sure if that would help out here cuz I never did go research exactly what was going on, but at this point it might be worth a shot.

If I add that code to my plugin or php file I get:

Warning: mysql_query(): 7 is not a valid MySQL-Link resource in [path]/includes/class_core.php on line 408 :(. I'm not trying to run a plugin on an external page I 'm trying to include my php file in the header template of vbulletin which contains $notifications_total in it. It works outside vB but in vB it doesn't work.

Lynne 04-20-2009 08:39 PM

OK, I'm not understanding something.... when you talk about the header template, you are talking about the regular vb header template, right? Not a special header template you wrote for another page. And in the header template, you have written the word "$notifications_total" that is giving the total in your vb pages but not your external page, right? Are you evaling the header template yourself, or is it getting evaled in the global.php file like normal?

And it sounds like you *are* trying to use a plugin to include your stuff. You said you were using the global_start plugin for your code. Is that not right? So, that is running the global_start plugin on your external page.

Perhaps you need to start posting your code, cuz I'm getting confused now with what you are doing.

ScottC2105 04-20-2009 09:23 PM

Quote:

Originally Posted by Lynne (Post 1795493)
OK, I'm not understanding something.... when you talk about the header template, you are talking about the regular vb header template, right? Not a special header template you wrote for another page. And in the header template, you have written the word "$notifications_total" that is giving the total in your vb pages but not your external page, right? Are you evaling the header template yourself, or is it getting evaled in the global.php file like normal?

And it sounds like you *are* trying to use a plugin to include your stuff. You said you were using the global_start plugin for your code. Is that not right? So, that is running the global_start plugin on your external page.

Perhaps you need to start posting your code, cuz I'm getting confused now with what you are doing.

Sorry Lynne. I have managed to get it to work by recoding my php file inside the vB header template using vBs if conditions and else etc. What was happening was, my login php file that is on all my pages shows a login box if you are not logged in. If you are logged in, it says hello and tells you if you have any current norifications. Now, this was working fine on all other pages EXCEPT for vBulletin. I used a plugin to include my login php file and the php file uses $notifications_total but for some reason, the included php file ON vBulletin pages was showing $notifications_total as "" (blank). So, I have rewritten the php file inside the header for my vBulletin template and $notifications_total works fine. The only thing is I now have a php file for my website and the same code in my header on vbulletin so if I ever want to change it I have to change my code in two places.

Thank you for all you help, much appreciated.

Lynne 04-20-2009 10:01 PM

Glad you got it working.


All times are GMT. The time now is 10:04 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.01002 seconds
  • Memory Usage 1,741KB
  • 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
  • (4)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete