Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 03-03-2004, 12:58 PM
TLCanna TLCanna is offline
 
Join Date: Feb 2003
Location: around here somewhere
Posts: 35
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Parse PHP in a Template

I have recently upgraded to VB3, my old boards had a banner rotator.php that was included in my header template.

My Problem:
When I do a PHP include like so <? include ("rotator.php");?> it displays the text on the screen. It doesn't actually parse the code and randomly rotate my banners.

Is there a command to force the template to parse the php code?
Reply With Quote
  #2  
Old 03-03-2004, 01:01 PM
NTLDR's Avatar
NTLDR NTLDR is offline
Coder
 
Join Date: Apr 2002
Location: Bristol, UK
Posts: 3,644
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You can only parse PHP code in the phpinclude_start and phpinclude_end templates.
Reply With Quote
  #3  
Old 03-03-2004, 01:03 PM
TLCanna TLCanna is offline
 
Join Date: Feb 2003
Location: around here somewhere
Posts: 35
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Do you indcate it to be parsed by a PHP command or what?
Reply With Quote
  #4  
Old 03-03-2004, 01:10 PM
NTLDR's Avatar
NTLDR NTLDR is offline
Coder
 
Join Date: Apr 2002
Location: Bristol, UK
Posts: 3,644
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You just place your PHP in the template as if it was a .php file.

PHP Code:
include('rotator.php'); 
Reply With Quote
  #5  
Old 03-03-2004, 01:38 PM
TLCanna TLCanna is offline
 
Join Date: Feb 2003
Location: around here somewhere
Posts: 35
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks NTLDR... That worked, but now I have a second question. While reading the help screen for phpinclude_start.... It says You can enter PHP code here. The phpinclude_start template is evaluated at the beginning of page execution and can be used for putting things into templates.

So it sounds like I can now include the phpinclude_start to any template and it can be be displayed accordingly.

My questions is, what is the syntax for inserting to a template, should I say include or drop it in as a variable in the template.

Anna

PS... Let me apologize in advance for dumb questions, my technical skills are green at best.

Reply With Quote
  #6  
Old 03-03-2004, 01:55 PM
NTLDR's Avatar
NTLDR NTLDR is offline
Coder
 
Join Date: Apr 2002
Location: Bristol, UK
Posts: 3,644
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If you follow the example in there:

PHP Code:
// Example of how to include a seperate file: 
ob_start();  
require(
"yourheader.html"); 
$headercontent ob_get_contents();  
ob_end_clean(); 
You could then put $headercontent (which should work in most cases, some templates will require $GLOBALS[headercontent]) will place the HTML found in yourheader.html where you have placed the variable.
Reply With Quote
  #7  
Old 03-06-2004, 04:39 AM
ixian's Avatar
ixian ixian is offline
 
Join Date: Oct 2001
Location: Denver, CO
Posts: 189
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I have a similar problem, but I'm having some difficulty.

The problem is, I'm trying to get a php script that makes it's own call to a different database on the same server, called "center".

The phpinclude_start statement looks like this:
Code:
ob_start();
require_once ('../center/activity.php');
$activity1 = ob_get_contents();
ob_end_clean();
But when that happens, I get database errors on my forums, saying it can't find variable this, variable that - it looks like once it switches to my "center" database it doesn't switch back to the vbulletin db.

I tried using

chdir("$/var/www/html/forums");

After the above include, but that did nothing.

Anyone have any ideas? I'm sure I'm doing something wrong here. I tried using "include" and "require" above as well.
Reply With Quote
  #8  
Old 03-06-2004, 06:37 PM
NTLDR's Avatar
NTLDR NTLDR is offline
Coder
 
Join Date: Apr 2002
Location: Bristol, UK
Posts: 3,644
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Whats the code in center.php? If it doesn't echo/print etc anything directly out then you just need the require_once() part in the php_include_start template.
Reply With Quote
  #9  
Old 03-06-2004, 08:28 PM
ixian's Avatar
ixian ixian is offline
 
Join Date: Oct 2001
Location: Denver, CO
Posts: 189
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It does echo/print stuff out, which is the problem.

I finally solved this by moving the table it uses over to the vbulletin database, and using it instead. It's a small, simple table with 3 rows and not a lot of information, so load isn't an issue, and it works now.

Kind of in-elegant for other types of php scripts though, but what can you do.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:57 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04268 seconds
  • Memory Usage 2,244KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (2)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (9)post_thanks_postbit_info
  • (9)postbit
  • (9)postbit_onlinestatus
  • (9)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete