vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   PHP in template (https://vborg.vbsupport.ru/showthread.php?t=96679)

unknowngiver 09-21-2005 10:16 PM

PHP in template
 
Hey

I really need help

i followed this tutorial to make my own page
https://vborg.vbsupport.ru/showthrea...4&page=1&pp=15

it works 100% fine if i add HTML to my custom page

BUT I WANT TO ADD php in my custom page and it wont work

the page just doesnt run the php commands...its just like EMPTY PAGE

can any1 help me? please

any1

unknowngiver 09-23-2005 03:09 PM

anyone :(

Andreas 09-23-2005 03:13 PM

You can't use PHP in Templates. Point.

pyro.699 09-25-2005 12:33 PM

umm, yeah, i was having this problem! but, ill show you how 2 fix it ^^

PHP Code:

ob_start(); 

all of your script, that you want to appear,

only do it for your suctom part, the stuff at the top, it alwasy works ^^
PHP Code:

$name_your_template_code ob_get_contents();
ob_end_clean(); 

now, go to oyur template and where you want the code to appear, type: $name_your_template_code

if you get stuck, lme know...

unknowngiver 09-27-2005 03:45 PM

k
can u explain this please
where do i add the PHP code in the code tht u gave me
lets say thts my php code

<?php
echo 'blah blah blah'
print ' test'
$name= 'test'
$name2 = 'test1'
echo $name . $name2
echo 'more php stuff
?>

How would i do that ?

and where do i add the code tht u provide me?

do i still use tht tutorial for custom page?

pyro.699 09-27-2005 08:37 PM

(yes, you need 2 do teh custom template)

ok, np...
PHP Code:

<?php
//all the template stuff for vbulletin, it is required
//put  ob_start(); around your custom code only
ob_start();
echo 
'blah blah blah'
print ' test'
$name'test'
$name2 'test1'
echo $name $name2
echo 'more php stuff
$randomname = ob_get_contents();
ob_end_clean()
?>

ok, now, if you have done your template, all you have to add is add
PHP Code:

$randomname 


hope this works ^^

Neutral Singh 09-28-2005 05:11 AM

useful stuff pyro, thanks

pyro.699 09-28-2005 09:32 AM

No prob, lme know if you need anything!

unknowngiver 11-24-2005 02:55 PM

k so pyro the code u gave me is for the template...not the php file right?

AutoXer 12-11-2005 01:12 AM

Quote:

Originally Posted by unknowngiver
k so pyro the code u gave me is for the template...not the php file right?


No. The php code goes in the php file. It must be placed before this line:

PHP Code:

eval('print_output("' fetch_template('test_mytesttemplate1') . '");'); 

In this case the only thing that gets added into the template is $randomname. Place it wherever you want the php code to go.


All times are GMT. The time now is 01:06 AM.

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.01032 seconds
  • Memory Usage 1,735KB
  • 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
  • (5)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete