Re: Smarty's Smartest Practices?

From: Date: Wed, 19 Feb 2003 16:18:35 +0000
Subject: Re: Smarty's Smartest Practices?
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-7896@lists.php.net to get a copy of this message
"Mike Van Lammeren" <mike@emerge2.com> wrote news:5.1.0.14.0.20030219101105.02b48b70@mail.emerge2.com... > Well, no offence to Tom, but I am curious about how people organize the > html in their templates. Over the years, we have done projects in ASP, > Perl, and most recently, PHP. (They'll get PHP away from me when they pry > it from my cold, dead hands!) We've tried a number of approaches when it > comes to laying out html templates, but more often than not, we settle on a > single page, which includes every tag from <html> to </html>. We keep this > page short, preferably under 100 lines, then include everything else from > other files, such as css, javascript, a layer for drop-down menus, etc. The > dynamic content is poured into a number of places, such as the body of the > page, a navigation side-bar, etc. I've done this up to this point as well, but now I've changed to my new way of doing it... and it works much better > If we had hundreds of pages with static bodies, then we would probably go > for an arrangement whereby the html making up the body would go in a file > which included header and footer files. (What Tom refers to as the "top and > bottom headers" approach.) What I do, I'm not sure you understand me (or I understand you), is that I have a file called index.tpl This fil contains all the basic structure of the site, like tables etc. Inside index.tpl I have blocks, which can be formed to whatever I like (Currently I have my menu inside a block and my other boxes (see tsn.dk), the most importent thing about the way my templates work is that I have a variable called CONTENT, where all my content from the other files go, these other files do not contain any stucture of the site, only of the current page (Like a list of news, nothing else). This way I can keep my index and entire stucture of the site in -one- file and change it whenever I want, without EVER having to change the other pages as well. The reason why I do not use top and bottom headers is that I cannot work with them in dreamweaver, they don't allow me to see the site and change a small thing without me having to slice up the site into bottom and top once again etc etc. Also, I include a file I call init.php on all pages, this file connects to the database and sets up index.tpl ready for parsing.... now, when I do a new design, I will only have to change init.php and index.tpl, all other things can run as they always have.... I love templates see http://build.tsn.dk which is where I am currently building with PHPLIB (not started on smarty yet, will start tomorrow) the build site can be slow, not because of the code I might add :) Phew, that was a long story, anyway.. any questions? -- Tom Sommer www.tsn.dk - www.dreamcoder.dk

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