RE: Design question

From: Date: Fri, 13 Jul 2001 11:12:59 +0000
Subject: RE: Design question
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-1154@lists.php.net to get a copy of this message
For my site, where I have a sort of similiar layout, I've made a table in a database where all the pages are stored. Like: news | news.tpl | script.news.php todo | todo.tpl | script.todo.php etc.. then I just do a SELECT * FROM mytable WHERE id='$id'; This is good because: * If I add a new page I only have to add a row in the database (can be done online!) * The same goes for renaming the page title which I also have stored in the same database. * Flexible.. Extendable.. better looking code.. And more I guess. Well, it's only a suggestion. No approach is the _best_. // Victor ----- Original Message ----- From: "Luc Saint-Elie" <luc@saint-elie.com> To: <smarty@lists.ispi.net> Sent: Friday, July 13, 2001 11:49 AM Subject: [smarty] Design question > Hello, > > This is probably a very basic question but... > > Context : > ====== > A website with a main template (lets call it index.tpl) that calls a lot of sub- > templates and a main central one where the main content is displayed. > > Depending on the navigation chosen by the visitor the main sub-templates > changes. > The url are of the form > > /index.php ?screen=news > for the news or > /index.php ?screen=todolist > for the todo list and so on > > In order to do this there are two ways (and perhaps more, its basicalyy my > question) > > Way 1 : > ====== > > In the index.tpl have a list of > {if $screen eq "news"} > {include file= "clientname.news.tpl"} > {else if $screen eq " todolist "} > {include file= "clientname.todolist.tpl"} > > .... > {/if} > > Way 2 > ==== > > In the index.tpl have only > {include file=$clienttemplate } > > and in index.php > > switch($screen) { > case 'news' : $clienttemplate = clientname.news.tpl ; > break ; > case 'todolist' : $clienttemplate = clientname.todolist.tpl ; > break ; > .... > } > > The question is : > > In PHP (and perhaps in other languages) for a huge number of options, switch is > quicker than if > So the logical choice would be to use way #2 > But in this case the switch must be added in all .php files making the site > maintenance a real assle > (each time a new template to be included is added, all .php files must be > updated) > On the other hand using way #1 allow to only one file (the index.tpl) to > maintain... but is slower. > > What is the right approach ? > > Luc > > --- > You are currently subscribed to smarty as: victorious81@hotmail.com > To unsubscribe send a blank email to $subst('Email.Unsub') > Visit Smarty's homepage at > http://www.phpinsider.com/php/code/Smarty/ >

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