Smarty's Smartest Practices?

From: Date: Wed, 19 Feb 2003 15:58:45 +0000
Subject: Smarty's Smartest Practices?
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-7891@lists.php.net to get a copy of this message
I've been lurking on this list for a little while now, and just want to say that Smarty is absolutely brilliant! I have completed a few commercial projects with Smarty, and find that it integrates perfectly with the way we develop. It's as though Smarty was custom-written for us. Thanks to everyone involved! A little while ago, Tom Sommer wrote:
I don't want to hear about including top and bottom headers, since I've worked that way for a long time and have come to love my new way of working with templates :)
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. Here is a simplified example: standard_page.tpl <html> <head> <title>ABC Company: {$title}</title> {include file="standard_header.tpl"} </head> <body> <table> <tr>
      <td colspan="2">
         {include file="top_menu_links.tpl"}
      </td>
</tr> <tr>
      <td colspan="2">
         <h1>ABC Company</h1>
         <h2>{$title}</h2>
         logged in as: {$login_name}
      </td>
</tr> <tr>
      <td>
         <h1>Side Menu</h1>
         {$side_menu_links.tpl}
      </td>
      <td>
         <!-- main page body -->
         {include file="some_body.tpl"}
      </td>
</tr> </table> </body> </html> What you should know about our projects is that they are typically database-driven web applications, with around 6 to 10 actual pages. While one page, for instance, may allow access to an archive of hundreds of press releases, it is still only one page to the webserver. 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.) Now that you know where Tom and I stand, what do you think? What do you do? -- Mike van Lammeren Web Application Developer Emerge2 Digital Inc., "evolving business to digital" Web: http://www.emerge2.com Email: mike@emerge2.com

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