vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Running PHP code in template (https://vborg.vbsupport.ru/showthread.php?t=148915)

MomentumInc 06-04-2007 07:53 PM

Running PHP code in template
 
Hi. The navigation for our main site is generated dynamically. I'd like to use the same navigation at the top of our forum. Essentially, all I really need to do is include a php file in the "header" template.

I'm sure this question has been answered many times before, but I've been searching and searching and can't find anything that explains it completely (just something about defining variables somewhere that can be used in templates? or using hooks?)

Thanks.

Dismounted 06-05-2007 07:36 AM

You will need to add a hook at global_start and use the ob_ functions. Searching on the vB.com forums would give you a few results. I'm also pretty sure it's in the manual somewhere as well.

Michael Morris 06-05-2007 01:20 PM

Quote:

Originally Posted by Dismounted (Post 1261618)
You will need to add a hook at global_start and use the ob_ functions. Searching on the vB.com forums would give you a few results. I'm also pretty sure it's in the manual somewhere as well.

Partially wrong. global_start is already wrapped in an object buffer to allow backward compatibility with other PHP_INCLUDE scripts from vb 3.0.x days. All that is needed for a dynamic header is to replace the content of the header template with the var $phpinclude_output and then put the include file in the global start hook to set it up.

He can put an object buffer in an object buffer, though there's little need to do so.

MomentumInc 06-05-2007 06:29 PM

Thanks. I figured out how to use hooks well enough to get Dismounted's suggestion working. I will look into the other suggestion as well if it's a 'better' way of doing it.


All times are GMT. The time now is 02: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.00901 seconds
  • Memory Usage 1,712KB
  • 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
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)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