templates_dir : a better way ?

From: Date: Sun, 24 Mar 2002 23:34:21 +0000
Subject: templates_dir : a better way ?
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-3317@lists.php.net to get a copy of this message
Hi All, Here are some ideas I have about template_dir and more generally about heritage in HTML / template / Css / images ... access in web sites. Let's say we run a web site under /WEBS/my_web/www Imagine we have Smarty installed under /WEBS/my_web/Smarty/ We have fon instance under www/ the directories www/products /company /private /stuff/friends /stuff/wap /stuff/new/stuff ... Smarty provides 2 method to load & use templates : 1. $smarty->display("a_template.tpl") // in the $smarty->templates_dir directory 2. $smarty->display("/WEBS/my_web/www/stuff/templates/a_template.tpl") // a realtive or absolute file I personnaly hate the second way because it makes the architecture path dependant as a Web is supposed to be DOCUMENT_ROOT relative at minimum and always relative if possible. So the first method is a good solution BUT force the webmaster to place any templates under a given directory (the $templates_dir). Here is an other way template load could work : Template could be loaded from any directory called ./template up to the top ./template dir using heritage Imagine we have : smarty/templates/ -index.tpl www/product/ /stuff/templates/ - index.tpl /stuff/new/templates/ - index.tpl then imagine we use $smarty->display("index.tpl") from the /www or /www/stuff/ or /www/stuff/new then smarty would call the nearest ./templates/index.tpl available. This way makes it very easy to change a paticular template in any branch of the Web without having to store a new template in the $template_dir This way makes it also much easier to maintain large webs with hundreds of templates, and avoiding to have many webmasters working in the same template_dir inclusion inside templates should also work this way, making it easy to have a page template and local blocs. I believe it could be quite easy to write a template selection function, but I'd like to have some point of views about this way of locating templates. ---- An other idea Smarty should help a bit more with CSS and navigator detection -> Css choice. The last thing - I'm french - excuse me for any mistakes in this mail. Thank you for any help / comment. Christophe Ruelle ruelle@xtof.com

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