Re: [SMARTY] insert: problem with a variable name attribute

From: Date: Mon, 12 Aug 2002 17:49:02 +0000
Subject: Re: [SMARTY] insert: problem with a variable name attribute
References: 1 2  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-5657@lists.php.net to get a copy of this message
Ferdinand Beyer schrieb in php.smarty.general: > On 8 Aug 2002 at 15:59, Thomas Schulz wrote: >> {foreach key=name item=plugin from=$view.main} >> plugin name: {$name}<br> >> {insert name=$name view=$plugin.view style=$plugin.style} >> {/foreach} > > Don't expect this to work. {insert} is not a "normal" smarty function > but treated special as it is used for data that shall not be cached. I know this, and that's exactly the reason why i make intensive use of insert plugins in my applications. In order to create modular cached pages, my main program defines the layout of the page in dependence of the application's mode. The layout (view) is defined as an array containing - which insert-plugin (news, forum, menu ...) - in which area of the page (head, main, right, left,...) shall deliver the content - in which view (search, list, katalog, item, ...). $view['area_name']['plugin_name']['view'] = 'view_name' Sample view defintion for a page displays a search form and the result list for "news", the navigation tree (right side) and the last forum postings (left side): $view['main'] ['news'] ['view'] = 'search'; $view['sub'] ['news'] ['view'] = 'list'; $view['right']['menu'] ['view'] = 'tree'; $view['left'] ['forum']['view'] = 'lastlist'; Whithout an dynamic "name" attribute, I either have to insert all plugins in each page area and evaluate $view inside every plugin - or I have stuff like this in each area of the general page template (currently working): <!-- main area of the page.tpl --> {if $view.main.news} {insert name="news" view="$view.main.news.view"} {/if} {if $view.main.forum} {insert name="forum" view="$view.main.forum.view"} {/if} {if $view.main.menu} {insert name="menu" view="sitemap"} {/if} > Smarty developers did not plan to make the "name" attribut dynamic. > Because of insert's special meaning, 'name' has to be a static value. Some more arguments would help me to respect this decision. Performance? Security? > Neither nor, its expected behavior. Don't use insert here. I have to and hope you now understand why. ;-) Regards, Thomas. -- Dipl. Ing. Thomas Schulz - http://4bconsult.de

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