vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=251)
-   -   How to add PHP in a custom template file? (https://vborg.vbsupport.ru/showthread.php?t=259378)

CampinCarl 02-24-2011 11:23 AM

How to add PHP in a custom template file?
 
I'm trying to make dynamic pages by using the tutorial on this page.

https://vborg.vbsupport.ru/showthread.php?t=228112

I've gotten it to work and all, but the only problem I have is adding PHP to the page. I've followed everything here.

http://www.vbulletin.com/docs/html/t..._externalfiles

What I did was I enabled plugins / hooks. I made a new plugin, global_start, etc. I dragged a file called test.php into my forum root, and I inserted the following code into the plugin.

PHP Code:

ob_start();
  include(
'test.php');
  
$includedphp ob_get_contents();
  
ob_end_clean(); 

I went back to my template and added {vb:raw includedphp}, and nothing happened. What am I doing wrong?

tonyvh2 02-24-2011 11:58 AM

try:

- filling in the complete path for example /complete/path/etc/test.php
- register template you are using where name of the template is "yourtemplate"

like this:
PHP Code:

ob_start();
  require_once(
'/complete/path/etc/test.php');
  
$includedphp ob_get_contents();
ob_end_clean();
vB_Template::preRegister('yourtemplate',array('includedphp' => $includedphp)); 


CampinCarl 02-24-2011 01:03 PM

Thank you!


All times are GMT. The time now is 05:07 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.00996 seconds
  • Memory Usage 1,714KB
  • 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_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (3)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