Design question : synthesis

From: Date: Fri, 13 Jul 2001 11:21:36 +0000
Subject: Design question : synthesis
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-1155@lists.php.net to get a copy of this message
Hello, At first I was afraid my question was really stupid, at the end it is but the answers are not. So here is a little synthesis hopping this could help. From the very straightforward Mike's approach (that requires a very vell defined file naming scheme) to Victor database based solution, there are huge differences.... I will probably go for Adi approach that seem to fit better the way I work. The question (short version) was : When a sub-template is changed based on an url variable (index.php? screen=variablename) -> what is the best way to deal with the variable/template association management ? ===================== Mike ================================ have you tried in index.tpl: {include file= "clientname.$screen.tpl"} ===================== Victor ================================ 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_. =========================== Adi ====================================== 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 } =====================================================================

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