Re: Design question
| From: | Adi Sieker | Date: | Fri, 13 Jul 2001 10:33:58 +0000 |
| Subject: | Re: Design question | ||
| References: | 1 2 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-1153@lists.php.net to get a copy of this message | ||
On Fri, 13 Jul 2001 11:49:50 +0200 (MEST), Luc Saint-Elie
<luc@saint-elie.com> wrote:
[snip]
>
>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 ?
Well you don't really need the whole switch in all the files.
Do could do something like:
-- screen-selection.inc.php --
function get_screen_tempalete($screen) {
switch($screen) {
case 'news' :
return = "clientname.news.tpl";
break ;
case 'todolist' :
return "clientname.todolist.tpl";
break ;
default:
return "screen-unknown.tpl";
}
}
-- index.php --
require "screen-selection.inc.php";
$smarty->assign("clienttemplate", get_screen_template($screen));
-- index.tpl --
{include file=$clienttemplate }
-------
Regards
Adi