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

How can I get this stuff from PHP to Smarty?

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 05-17-2004, 04:20 PM
 
ngwheels ngwheels is offline
 

Member
  
Join Date: Feb 2004
Posts: 12
 

Default 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.
__________________
Cart 3.5.4
Reply With Quote
  #2  
Old 05-17-2004, 06:53 PM
  BCSE's Avatar 
BCSE BCSE is offline
 

X-Guru
  
Join Date: Apr 2003
Location: Ohio - bcsengineering.com
Posts: 3,091
 

Default

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
__________________
Custom Development, Custom Coding and Pre-built modules for X-cart since 2002!

We support X-cart versions 3.x through 5.x!

Home of the famous Authorize.net DPM & CIM Modules, Reward Points Module, Point of Sale module, Speed Booster modules and more!


Over 200 X-cart Mods available & Thousands of Customizations Since 2002 - bcsengineering.com

Please E-Mail us for questions/support!
Reply With Quote
  #3  
Old 05-17-2004, 09:53 PM
  Waylon's Avatar 
Waylon Waylon is offline
 

Newbie
  
Join Date: May 2004
Posts: 9
 

Default 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.
Reply With Quote
  #4  
Old 05-18-2004, 03:40 PM
 
ngwheels ngwheels is offline
 

Member
  
Join Date: Feb 2004
Posts: 12
 

Default

Thanks for the advice, I'll be playing with it tonight to see if I can figure something out.
__________________
Cart 3.5.4
Reply With Quote
  #5  
Old 05-18-2004, 04:08 PM
 
ngwheels ngwheels is offline
 

Member
  
Join Date: Feb 2004
Posts: 12
 

Default

I can't believe I put this off for so long, its probably the easiest thing I've done with this site. Thanks guys.
__________________
Cart 3.5.4
Reply With Quote
  #6  
Old 05-18-2004, 07:24 PM
 
Mod King Mod King is offline
 

Senior Member
  
Join Date: May 2004
Posts: 115
 

Default

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.
__________________
Mod King
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 03:50 PM.

   

 
X-Cart forums © 2001-2020