Page 1 of 1

How to set up a smarty array in a template?

Posted: Thu Aug 21, 2008 2:39 pm
by applejack
Hi

I am trying to pass the values of a smarty loop into a javascript array. I suspect I may have to first pass the values to a Smarty array and then assign that to the javascript array but I am unsure how to declare a smarty variable as an array. This has to happen in a template because I am using smarty to dig out the data. i.e.



var data = new Array();

{foreach from=$cgsimple->get_children('$page_alias','0') item='child'}
{assign var='smarty_data' value=$cgsimple->get_page_content($child.alias,'Photo_Name')}
data = {$smarty_data};
{/foreach}

{literal}
// the values of the javascript array data are used in the function below

window.addEvent('domready', function() {
var myShow = new Slideshow.KenBurns('show', data, { captions: true, controller: true, delay: 4000, duration: 2000, height: 515, hu: '/uploads/filepath/', width: 774 });
})

{/literal}



So instead of having data = {$smarty_data}; in the loop I presume I need to use a Smarty arry to capture the data and then pass it to the javascript data array after the loop has finished.


All and any help much appreciated.

Re: How to set up a smarty array in a template?

Posted: Tue Oct 21, 2008 7:54 am
by chuckienorton
I'm looking for the same thing. Did you ever figure it out?

~Chuck

Re: How to set up a smarty array in a template?

Posted: Tue Oct 21, 2008 10:33 am
by applejack
Hi see this post

http://forum.cmsmadesimple.org/index.ph ... #msg121614

What exactly are you trying to do?