vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Member Archives (https://vborg.vbsupport.ru/forumdisplay.php?f=202)
-   -   Declaring and Using PHP variables (https://vborg.vbsupport.ru/showthread.php?t=18187)

zxb 05-26-2001 10:41 AM

Lets say I created a php function xyz() and subsequently assigns its output to a variable $abc.

Now, I want $abc's value to appear in the template named "head". Apparently, simply editing the template and adding $abc to the desired location in the template does not produce the desired final output. The value of $abc is not displayed.

The template "head" itself contains VBB's original program variables like "$bbtitle" and these are substituted correctly. So how do I make my custom var "$abc" do that?

Thanks in advance.

The Snake 05-26-2001 11:20 AM

did u create the function xyz() in the same file where you are calling it from?
otherwise you should require the file the function is in, for example xyz.php by adding this line into the head template:

PHP Code:

require("xyz.php"


tubedogg 05-26-2001 08:00 PM

PHP is not parsed in the templates, except for the phpinclude template. You will either have to add it to that (but remember to assign it to a variable, don't output it directly) or put it in global.php around where it declares the header and footer.

zxb 05-27-2001 06:40 AM

Thanks for the replies.

tubedogg, I'm trying to do what you suggested:

1) in phpinclude template, I've added the following lines:
include("myhacklib.inc"); // my custom codes
$myvar = myfunction(.....);

2) Added $myvar into the desired template and everything gets parsed and displayed as desired.

What I'm concerned about is whether there'll be any performance issues involved cos the stuff in "phpinclude" template is probably applied to all pages in the BB. So if I've functions that I only require in say, the BB home page, is there any other place I can place it and still get the same results?

JamesUS 05-27-2001 08:07 AM

You would then need to put it in the actual PHP file of the page, eg for forumhome it needs to go somewhere in index.php


All times are GMT. The time now is 11:47 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.00908 seconds
  • Memory Usage 1,715KB
  • 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
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)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