vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   How can I access a new variable within a template? (https://vborg.vbsupport.ru/showthread.php?t=79849)

gnawph 04-13-2005 03:04 AM

How can I access a new variable within a template?
 
I've used this tutorial to make a simple page. The goal is to create a movie viewer. I need to have access to a new variable inside of a template file so I can use conditionals on my new variable to make something happen.

For example here is my ideal template:
HTML Code:

<div>
    <if condition="$my_new_variable">Do this</if>
</div>


Adrian Schneider 04-13-2005 03:08 AM

That's correct, you may want to add a value to it, such as
HTML Code:

<if condition="$my_new_variable == 1">.
What is the problem? You will need to define the variable in your PHP file first.
PHP Code:

$my_new_variable 1


gnawph 04-16-2005 03:45 AM

Thanks

I'm not really sure why my variable wouldn't work before. All kosher now, thanks!

Illthis 03-12-2009 11:41 AM

I have the same Problem:

I want to use a variable
$tight_editor
in my
editor_toolbar_on template

which i declared in my profile.php on the first hook which is called profile_start

unfortunately in my editor i can't echo the variable

any ideas

solita_ugc 05-11-2009 06:29 AM

Quote:

Originally Posted by SirAdrian (Post 639894)
That's correct, you may want to add a value to it, such as
HTML Code:

<if condition="$my_new_variable == 1">.
What is the problem? You will need to define the variable in your PHP file first.
PHP Code:

$my_new_variable 1


Should the variable be defined global?

warrentr2 05-27-2009 12:22 AM

Hello,
I battled with a similar issue for quite some time and noticed the following:
Lets say I want to display a debug variable in the header template like:
HTML Code:

<div>$debugMsg</div>
That var must be set BEFORE global_setup_complete. For example, if I make the var
PHP Code:

$debugMsg "Test Message"

in the global_setup_complete hook, the header template will never display anything. However, if I move the above php to global_start, it works as intended.

This is great if you want your code to be in global_start, but what if you need it later? Does anyone know a simple way to change the already processed templates?


All times are GMT. The time now is 11:21 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.01043 seconds
  • Memory Usage 1,726KB
  • 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
  • (4)bbcode_html_printable
  • (3)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)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