Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Create an Array that interacts with CS-Cart Smarty Variables Rate Topic   - - - - -

 
  • Yokimato
  • Newbie
  • Members
  • Join Date: 20-Jan 12
  • 5 posts

Posted 26 January 2012 - 01:09 AM #1

I'm new to Smarty and CS-Cart in general,


I was able to create a foreach loop in smarty, outputting a list of categories:

{foreach from=$categories item="category" name="categories"}
  {$category.category}
{/foreach}

That works, but now I'm trying to create an array with the information, but I don't know where to begin.

I tried doing it in html, putting my code in between {php} {/php} tags, but cscart seemed to ignore it all together.

 
  • solesurvivor
  • Senior Member
  • Members
  • Join Date: 05-Aug 11
  • 745 posts

Posted 26 January 2012 - 03:04 AM #2

Please explain further? You San to store the info from cs cart array into. A new array??

 
  • Yokimato
  • Newbie
  • Members
  • Join Date: 20-Jan 12
  • 5 posts

Posted 26 January 2012 - 03:07 AM #3

thank you for responding!

Yes, I'm trying to store information from a CS Cart array into my own array. I'm doing this because I'm trying to write a custom PHP function on a product list template.

I don't know the first thing about doing that in CS Cart.

 
  • solesurvivor
  • Senior Member
  • Members
  • Join Date: 05-Aug 11
  • 745 posts

Posted 26 January 2012 - 04:34 AM #4

Just change the setting in config.local.php to allow php template code in templates.

 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11248 posts

Posted 26 January 2012 - 05:12 AM #5

don't use PHP in templates!!!

If you have a PHP array just assign it to a template variable in your PHP code like:
Registry::get('view')->assign('name_of_variable', $array_data);

Embedding PHP code in templates is not only bad design, but it causes the template engine to recurse which chews up performance.

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.