How to set up a smarty array in a template?

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
applejack
Power Poster
Power Poster
Posts: 1014
Joined: Fri Mar 30, 2007 2:28 am
Location: London

How to set up a smarty array in a template?

Post 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.
Last edited by applejack on Thu Aug 21, 2008 9:11 pm, edited 1 time in total.

Website Design & Production
http://www.applejack.co.uk
User avatar
chuckienorton
Forum Members
Forum Members
Posts: 68
Joined: Wed Feb 14, 2007 6:58 pm
Location: Pasadena, California

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

Post by chuckienorton »

I'm looking for the same thing. Did you ever figure it out?

~Chuck
applejack
Power Poster
Power Poster
Posts: 1014
Joined: Fri Mar 30, 2007 2:28 am
Location: London

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

Post by applejack »

Hi see this post

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

What exactly are you trying to do?

Website Design & Production
http://www.applejack.co.uk
Post Reply

Return to “Developers Discussion”