vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   putting PHP in style templates (https://vborg.vbsupport.ru/showthread.php?t=98161)

RossOliver 10-11-2005 08:03 PM

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

Andreas 10-11-2005 08:05 PM

1) You can't use PHP in Templates
2) Templates are stored in the Database (table template) and not in files.

untold4you 10-11-2005 08:10 PM

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.

RossOliver 10-11-2005 08:35 PM

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

Andreas 10-11-2005 08:42 PM

This is a FAQ ;)

global_start
PHP Code:

ob_start();
include(
'/path/to/script.php');
$script_output ob_get_contents();
ob_end_clean(); 


KW802 10-11-2005 08:43 PM

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?

RossOliver 10-11-2005 08:45 PM

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

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

Andreas 10-11-2005 08:47 PM

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.

RossOliver 10-11-2005 09:07 PM

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

Andrew 10-11-2005 11:18 PM

'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'


All times are GMT. The time now is 04:06 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.01014 seconds
  • Memory Usage 1,738KB
  • 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_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete