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

Use variables from smarty in PHP

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 09-09-2003, 07:53 PM
  finestshops's Avatar 
finestshops finestshops is offline
 

eXpert
  
Join Date: Oct 2002
Location: Toronto, Canada
Posts: 335
 

Default Use variables from smarty in PHP

Help guys!!!

I'm trying to assign variable in welcome.tpl:

{ config_load file="special.tpl" }
- works fine - get parsed to other tpl as {#specialid#}

and tried this one

{assign var="specialid" value="71"}
- works too - get parsed to other tpl as {$specialid}

how to use this variable in php script which is included
in home.php like this:

include "../modules/Special/special.php";

???

Everything works if I hard code variable directly
in php, but I have to send it from tpl

Is there anything like "$smarty.specialid" to use in php scripts?

Thank you
__________________
Best regards,

Anton Pachkine
finestshops.com/x-cart
Reply With Quote
  #2  
Old 09-09-2003, 10:07 PM
 
funkydunk funkydunk is offline
 

X-Man
  
Join Date: Oct 2002
Location: Cambridge, UK
Posts: 2,210
 

Default

Smarty is designed to do this the other way around, i.e. assign the variables in the php script and then give it to smarty to display through the template system.
__________________
ex x-cart guru
Reply With Quote
  #3  
Old 09-10-2003, 11:31 AM
  finestshops's Avatar 
finestshops finestshops is offline
 

eXpert
  
Join Date: Oct 2002
Location: Toronto, Canada
Posts: 335
 

Default

> Smarty is designed to do this the other way around

I know, but I have to send variable which is assigned by store admin.
The easiest way would be assigned it in "Edit Templates" but I can not
send it to php script. Any ideas on how to give admin ability to set some custom variable for the whole store whithout modifying php scripts every time?

Thanks
__________________
Best regards,

Anton Pachkine
finestshops.com/x-cart
Reply With Quote
  #4  
Old 09-10-2003, 01:56 PM
  finestshops's Avatar 
finestshops finestshops is offline
 

eXpert
  
Join Date: Oct 2002
Location: Toronto, Canada
Posts: 335
 

Default



Wow! I love x-guys!!!

All I had to do is

Code:
INSERT INTO xcart_config VALUES ('specialid', 'Special Product id (leave empty if not needed)', '64', 'Appearance', 300, 'text');

and now I can use this variable in any php

Code:
$specialid = $config["Appearance"]["specialid"];

and master can modify it in
"Control panel" -> "General" -> "Appearance"

Could not be better!

Uraaaa! to x-men!

__________________
Best regards,

Anton Pachkine
finestshops.com/x-cart
Reply With Quote
  #5  
Old 09-10-2003, 09:59 PM
 
funkydunk funkydunk is offline
 

X-Man
  
Join Date: Oct 2002
Location: Cambridge, UK
Posts: 2,210
 

Default

You could just refer to it in a template by:

Code:
{$config.Appearance.specialid}
__________________
ex x-cart guru
Reply With Quote
  #6  
Old 09-11-2003, 08:55 AM
  finestshops's Avatar 
finestshops finestshops is offline
 

eXpert
  
Join Date: Oct 2002
Location: Toronto, Canada
Posts: 335
 

Default

> You could just refer to it in a template

I know, but I have to get all product info for this id first
from the database.

Thank you
__________________
Best regards,

Anton Pachkine
finestshops.com/x-cart
Reply With Quote
  #7  
Old 09-11-2003, 09:01 AM
 
funkydunk funkydunk is offline
 

X-Man
  
Join Date: Oct 2002
Location: Cambridge, UK
Posts: 2,210
 

Default

No you dont, anything that has been entered in the config or languages table in xcart is automatically available right through the template.

Just need to type in as shown
__________________
ex x-cart guru
Reply With Quote
  #8  
Old 09-11-2003, 09:46 AM
  finestshops's Avatar 
finestshops finestshops is offline
 

eXpert
  
Join Date: Oct 2002
Location: Toronto, Canada
Posts: 335
 

Default

I needed admin to be able to enter product id for special product to display on home page:

Ex: http://www.ontoppaintball.com

Yes, I have product id; but I also need product name, thumbnail, price and etc. for this product. Same as bestsellers module works but with only one product with id assigned by store admin.

I get "$specialid" and use it in "special.php" to select all info for this product and store it in "$special".
Now I can use all the info such as "$special.product", "$special.desc" and etc. in templates.

So, adding this variable into templates was not enough. Yes, I could get tumbnail and link to product page, but not product name and price.
__________________
Best regards,

Anton Pachkine
finestshops.com/x-cart
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 01:56 PM.

   

 
X-Cart forums © 2001-2020