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)
-   -   How can I get this stuff from PHP to Smarty? (https://forum.x-cart.com/showthread.php?t=7624)

ngwheels 05-17-2004 04:20 PM

How can I get this stuff from PHP to Smarty?
 
I'm still trying to learn this smarty templating, much more of a learning curve then I was expecting...Anyway, how do you think I could get something like the following to show up properly in the page? Lets say I have an array of

$test = array(blue, yellow, red, orange);

How can I get this to show up in a select box on my page? The will be dynamic based upon a couple variables received by the page, thats why I don't just type them straight into the template...

Thanks in advance for your help, I appreciate all the help I've gotten so far.

BCSE 05-17-2004 06:53 PM

Something like this assuming you're using the get method of a form. This also assumes you've passed $test properly to smarty.


Quote:

<select name=dropdown_name>
{section name=test_idx loop=$test}
<option value={$test[test_idx]} {if $smarty.get.category eq $test[test_idx]}selected{/if}>{$test[test_idx]}</option>
{/section}
</select>



Carrie

Waylon 05-17-2004 09:53 PM

Re: How can I get this stuff from PHP to Smarty?
 
Quote:

Originally Posted by ngwheels
$test = array(blue, yellow, red, orange);

How can I get this to show up in a select box on my page? The will be dynamic based upon a couple variables received by the page, thats why I don't just type them straight into the template...


I found this snippet on the Zend site (http://www.zend.com/zend/tut/tutorial-cezar.php):

You can create an array in PHP an pass it to the template:

Code:

$tmp = array ( 'UID'=> '10',  &'Name' => 'John Doe', 'Address'=>'Home address');
$smarty->assign('info', $tmp);


Then build the drop-down from the array. I haven't tried it, but it looks pretty straightforward.

ngwheels 05-18-2004 03:40 PM

Thanks for the advice, I'll be playing with it tonight to see if I can figure something out.

ngwheels 05-18-2004 04:08 PM

I can't believe I put this off for so long, its probably the easiest thing I've done with this site. Thanks guys.

Mod King 05-18-2004 07:24 PM

Smarty is a very simple program to do some awesome html stuff


check out http://smarty.php.net
and check out the documentation it has all the functions and some good examples.


All times are GMT -8. The time now is 03:39 PM.

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