vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   External file import question (https://vborg.vbsupport.ru/showthread.php?t=289877)

Vcize 10-30-2012 04:57 AM

External file import question
 
I am attempting to include a navigation bar at the top of my site and have followed some of the guides to do so using an external php script. However, the only way I've been able to figure out to do it is by creating the plugin and then including the plugin in each of my templates via a variable.

For instance...

Plugin code
Code:

ob_start();
  require_once('foo/foo.php');
  $foo_include = ob_get_clean();
ob_end_clean();

That runs on global_start.

Then, in my template I call $foo_include and that imports my foo.php file.

Is there a way I can hook into the templates to automatically include all the plugins at the very beginning of each template without the user having to add the variable manually? It needs to be the very first thing run, before any other elements are rendered.

Simon Lloyd 10-30-2012 07:37 AM

Why not include the variable in the header template?, it will then be available regardless of what you're looking at in your forum.

Vcize 10-30-2012 06:39 PM

Quote:

Originally Posted by Simon Lloyd (Post 2376994)
Why not include the variable in the header template?, it will then be available regardless of what you're looking at in your forum.

That's what I've done. However, if I switch themes I'll have to add it in the header template for that theme. Likewise, if I release it as a plugin then whomever uses it will have to add the variable manually.

Most plugins I download don't require me to make any manual edits so I'm guessing there is some way around this.

Simon Lloyd 10-30-2012 09:46 PM

So do an str replace as a plugin to add the variable to th header using global start or global complete as the hook

Vcize 10-31-2012 03:00 AM

I have that a shot by adding a plugin with the following code (the call to logo is the first thing in the header)...

Code:

ob_start();
  echo str_replace('<!-- logo -->', '$gamestabar_include <!-- logo -->', '<!-- logo -->');
ob_end_clean();

However it doesn't appear to be showing up. I'm sure there is another way to do this as well as many of the other plugins I use insert new hooks in all themes (like vbshout), but I can't follow their code structure.

Simon Lloyd 10-31-2012 06:06 AM

Check out this https://vborg.vbsupport.ru/showthread.php?t=263517 or even better this https://vborg.vbsupport.ru/showthread.php?t=286403


All times are GMT. The time now is 09:25 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.00954 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
  • (2)bbcode_code_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)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