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 10-11-2005, 08:03 PM
RossOliver RossOliver is offline
 
Join Date: Sep 2005
Posts: 28
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default putting PHP in style templates

Hey,

How can I include a PHP script in the navbar style template?

Alternatively, where can I find the navbar template in a PHP file rather than through the admin cpanel...

Cheers,

-Ross
Reply With Quote
  #2  
Old 10-11-2005, 08:05 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

1) You can't use PHP in Templates
2) Templates are stored in the Database (table template) and not in files.
Reply With Quote
  #3  
Old 10-11-2005, 08:10 PM
untold4you's Avatar
untold4you untold4you is offline
 
Join Date: Feb 2005
Location: In Tyranny
Posts: 25
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by RossOliver
How can I include a PHP script in the navbar style template?
php in a template is not possible, you can however output strings into it.

Check this topic, you will learn much on how vb works:
https://vborg.vbsupport.ru/showpost....13&postcount=1

Quote:
Originally Posted by RossOliver
Alternatively, where can I find the navbar template in a PHP file rather than through the admin cpanel...
You can't cause all templates are located in the database and not in the form of a file.
Reply With Quote
  #4  
Old 10-11-2005, 08:35 PM
RossOliver RossOliver is offline
 
Join Date: Sep 2005
Posts: 28
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

urgh, I can't get my head round this :ermm:

Ok, I have my php script which now just returns a load of HTML in a single variable.

What I don't understand is how to get that variable into the template. Do I some how use an 'xml hook' so I could include it something like;

<myphpscript>
parameters here if I want...
</myphpscript>

If that is the case, is there some kind of template I can alter that will show me the basic idea of how to do this?

Thanks,

-Ross
Reply With Quote
  #5  
Old 10-11-2005, 08:42 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This is a FAQ

global_start
PHP Code:
ob_start();
include(
'/path/to/script.php');
$script_output ob_get_contents();
ob_end_clean(); 
Reply With Quote
  #6  
Old 10-11-2005, 08:43 PM
KW802's Avatar
KW802 KW802 is offline
 
Join Date: Jul 2003
Location: A galaxy far, far away...
Posts: 1,450
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

In short... normally you can use PHP in HTML like you're thinking but you can't do it in vB templates... if you dig around either vB.org or vB.com you'll come across a thread where it's discussed that the ability of doing PHP in templates is prevented for security concerns.

To do what you want... are you trying to show a new page using vB's header & footer (and style) or are you trying to just include one or two new fields on an existing vB page somewhere?
Reply With Quote
  #7  
Old 10-11-2005, 08:45 PM
RossOliver RossOliver is offline
 
Join Date: Sep 2005
Posts: 28
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Alright, but where does that go and how does it make it's way into the template?

Cheers,

-Ross

Quote:
Originally Posted by KW802
In short... normally you can use PHP in HTML like you're thinking but you can't do it in vB templates... if you dig around either vB.org or vB.com you'll come across a thread where it's discussed that the ability of doing PHP in templates is prevented for security concerns.

To do what you want... are you trying to show a new page using vB's header & footer (and style) or are you trying to just include one or two new fields on an existing vB page somewhere?
I'm just trying to include a few lines of returned text in a div table under the navbar...

-Ross
Reply With Quote
  #8  
Old 10-11-2005, 08:47 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

As said - global_start.
Then just use the variable created by your script (and/or $script_output if it directly generates output) in the Template you want it.
Reply With Quote
  #9  
Old 10-11-2005, 09:07 PM
RossOliver RossOliver is offline
 
Join Date: Sep 2005
Posts: 28
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ah ok I think I understand now - but I think im going crazy, what on earth is 'global_start'? a file, template, something in the admincp :ermm:

-Ross
Reply With Quote
  #10  
Old 10-11-2005, 11:18 PM
Andrew's Avatar
Andrew Andrew is offline
 
Join Date: Nov 2004
Location: Pennsylvania
Posts: 441
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

'global_start' is a hook location where you can place PHP code that will be ran on every page - You can add a hook to it in the AdminCP under 'Plugin System > Add New Plugin'
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 06:02 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.02466 seconds
  • Memory Usage 2,253KB
  • 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_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete