Re: [SMARTY] Seperation of Logic and Presentation

Markku Niskanen <[email protected]>
Newsgroups gmane.comp.php.smarty.general
Message-ID <[email protected]>
On Fri, 29 Jul 2005 13:49:30 -0400, you wrote:

>What do you guys think?

Well, this thread is a truly interesting one. It would be nice
to collect all wisdom and the various approaches together as
this is a very common problem and various approaches fit 
for various tasks, I suppose.

As for myself most of my in-hoiuse applications are very simple
database browses/updates/reports and we have a very simple
header/left_menu/workarea approach. The main.tpl is basically:

<html>
<body>
<table>
  <tr><td>header stuff</td></tr>
  <tr>
    <td width=200>{$menu}</td>
    <td>{$content}</td>
  </tr>
</table>

The $menu is filled by ai instance of a menu class and a script
that fills the menu according to login/user/group information.

The $content is filled by my browse/edit/other classes or scripts
and the index.php is normally something like the code below. I am
using get/put method variable $act as the active script include 
file name.

<?php
  include "/lib/Smarty/Smarty.php";
  include "config/config.php";
  include "/utils/utils.php";
  include "/utils/session.php";
 
 // build menu class instance and fill the {$menu} variable
  include "scripts/menuis.php"; 

 // fetch stuff from the active script (browse_customer. php 
 // for instance, if $act=="browse_customer")

  if (file_exists("scripts/".$act.".php"))
    include("scripts/".$act.".php");
  else
    include("$root_path/common/default.php");
  $smarty->display("main.tpl"); 

?>

Depending on the application we are using our basic set of
templates (browse/update_form/report) and a mixture of
Smarty-driven ad-hoc templates or quick_and_dirty PHP code
when there is no need for elegancy. Every time, however, it
is Smarty that finally displays the page.

This is about as simple as it can get and suits very well for our
ultra-rapid application development which also quickened by a
set of wizards that create most of the basic screens friom the SQL
definition in minutes .

As for the classes I will publish at least some of them during 
the autumn.

Markku

-- 
Smarty General Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.