Re: dynamic inserts

From: Date: Fri, 13 Dec 2002 12:19:25 +0000
Subject: Re: dynamic inserts
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-6794@lists.php.net to get a copy of this message
paul@dostuff.net schrieb in php.smarty.general: > This question has been asked before, My solution (for the list archive) ;-) The array $view, that defines which plugin should insert in which area of page looks like that: $view [AREA][PLUGIN][PARAM] = 'VALUE'; An sample: ... > $view ['main'] ['tool'] ['view'] = 'index'; > $view ['main'] ['tool'] ['style'] = 'detailed'; ... From that we will produce an insert in the main area of a page that looks like: {insert name=tool area="main" view="index" style="detailed"} I now prepare smarty-code for the insert-statments in my main php-script... ------------------------------------------------------------- // initialize $plugcode-array $plugcode = array('head' => '', 'main' => '', 'sub' => '', 'side' => ''); // make the smarty-insertcode from $view array foreach($view as $area => $plugins) { $plugcode[$area] = ''; foreach($plugins as $name => $params) { $plugcode[$area] .= '{insert name=' . $name . ' area="' . $area . '"'; foreach($params as $key => $value) { $plugcode[$area] .= ' ' . $key . '="' . $value . '"'; } $plugcode[$area] .= '}'; } } $tpl->assign('plugins', $plugcode); ------------------------------------------------------------- ...and eval them in the template: <!-- main area of the interface --> {eval var=$plugins.main} ThS. -- http://4bconsult.de

« previous php.smarty.general (#6794) next »