Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Passing Variables between tpl files.

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 03-25-2006, 09:42 AM
 
jherzog jherzog is offline
 

Advanced Member
  
Join Date: Jan 2006
Posts: 93
 

Default Passing Variables between tpl files.

I think this is a basic question. I know php well but not smarty.

Any given X-Cart page loads many tpl files, which can be identified in the debug console.

If I assign a variable in a tpl file.

Code:
{assign var="VarName" value="MyValue"}

and the wish to call that variable in a different tpl that is loaded later it does not seem to be there.

If these tpls are loaded just like standard php includes this should work, but it doesn't.

The only two things I can think of is that these tpls are not loaded like standard php includes or the Debug console is not listing the tpls in the order they are loaded.

Any suggestions? Thank you.

Jed
__________________
Jed Herzog
Gold X-Cart 4.0.17
http://www.outliersolutions.com
Portland Advertising Agency,
Portland Web Design
Reply With Quote
  #2  
Old 03-26-2006, 07:06 AM
 
geckoday geckoday is offline
 

X-Wizard
  
Join Date: Aug 2005
Posts: 1,073
 

Default Re: Passing Variables between tpl files.

Quote:
Originally Posted by jherzog
...

Code:
{assign var="VarName" value="MyValue"}

and the wish to call that variable in a different tpl that is loaded later it does not seem to be there.

...
You need to explicitly pass variables to included tpl files like this:

Code:
{include file="another.tpl" var2=$VarName}
This will make $VarName from the main tpl available as $var2 in the included tpl.
__________________
Manuka Bay Company
X-Cart Version 4.0.19 [Linux]

UGG Boots and other fine sheepskin products
http://www.snowriver.com
Reply With Quote
  #3  
Old 03-27-2006, 11:19 AM
 
jherzog jherzog is offline
 

Advanced Member
  
Join Date: Jan 2006
Posts: 93
 

Default

humm..

what if you have one file with two includes.

Main.tpl
Code:
{include file="file1.tpl"} {include file="file2.tpl"}

and you define a variable in the first include "file1.tpl" but want the second include "file2.tpl" to have access to it. You are not including the second include in the first. Rather it is just loading after it. Is this possilbe?
__________________
Jed Herzog
Gold X-Cart 4.0.17
http://www.outliersolutions.com
Portland Advertising Agency,
Portland Web Design
Reply With Quote
  #4  
Old 03-27-2006, 01:51 PM
 
geckoday geckoday is offline
 

X-Wizard
  
Join Date: Aug 2005
Posts: 1,073
 

Default

Quote:
Originally Posted by jherzog
humm..

what if you have one file with two includes.

Main.tpl
Code:
{include file="file1.tpl"} {include file="file2.tpl"}

and you define a variable in the first include "file1.tpl" but want the second include "file2.tpl" to have access to it. You are not including the second include in the first. Rather it is just loading after it. Is this possilbe?
Smarty doesn't have this capability.
__________________
Manuka Bay Company
X-Cart Version 4.0.19 [Linux]

UGG Boots and other fine sheepskin products
http://www.snowriver.com
Reply With Quote
  #5  
Old 03-27-2006, 03:16 PM
 
jherzog jherzog is offline
 

Advanced Member
  
Join Date: Jan 2006
Posts: 93
 

Default

Okay, thanks for your help.

I have decided to explain why I want this functionality in case someone has a good idea.

This new post is http://forum.x-cart.com/viewtopic.php?t=27609
__________________
Jed Herzog
Gold X-Cart 4.0.17
http://www.outliersolutions.com
Portland Advertising Agency,
Portland Web Design
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 08:58 PM.

   

 
X-Cart forums © 2001-2020