X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Use variables from smarty in PHP (https://forum.x-cart.com/showthread.php?t=4294)

finestshops 09-09-2003 07:53 PM

Use variables from smarty in PHP
 
Help guys!!! :cry:

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

funkydunk 09-09-2003 10:07 PM

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.

finestshops 09-10-2003 11:31 AM

> 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

finestshops 09-10-2003 01:56 PM

:lol:

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!

:lol:

funkydunk 09-10-2003 09:59 PM

You could just refer to it in a template by:

Code:

{$config.Appearance.specialid}

finestshops 09-11-2003 08:55 AM

> 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

funkydunk 09-11-2003 09:01 AM

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

finestshops 09-11-2003 09:46 AM

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.


All times are GMT -8. The time now is 09:46 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.