array question

slava_mikerin

Joined: 2006-09-29
Posts: 1
Posted: Fri, 2006-09-29 20:44

hello,
i am developing a gallery 2 book theme and need to pass to album.tpl an array of text fields

in theme.inc i add an array to params

Quote:
function BookTheme() {
global $gallery;
...

$this->setParameter('page_tpl', array('index.tpl', 'intro.tpl', 'chapter1.tpl'));
}

in album.tpl i try to print out the values from the array

Quote:
{foreach from=$theme.params.page_tpl item=tpl}
<div>{$tpl}</div>
{/foreach}

but the only thing that gets printed out on the page is word

Quote:
Array

please help the newbee :)

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Tue, 2006-10-03 18:57

don't add code in the constructor. in showAlbumPage do
$template->setParameter('page_tpl', array(...));
then in album.tpl
{foreach from=$page_tpl item=tpl}...{/foreach}
or if your showAlbumPage gets a reference to $theme from the $template then you can do $theme['page_tpl'] = array(...); and reference $theme.page_tpl in your tpl.