Re: [SMARTY] Seperation of Logic and Presentation
Davide Muzzarelli <[email protected]>
| Newsgroups | gmane.comp.php.smarty.general |
|---|---|
| Message-ID | <[email protected]> |
Alle 19:49, venerdì 29 luglio 2005, Evan Wagner ha scritto:
> I've been using Smarty for a couple years now. Recently I've
> questioned my method of separating Logic and Presentation and have
> come up with two ways to solve it.
> [...]
> What do you guys think?
Hi Evan, hi group,
sorry in advance for my awful english.
I have implemented a MVC pattern by build a framework. I will release that
framework, Fraw, when it is complete whit a GPL like license. At now, I am
the only developper. You can see my website for a preview (also
www.villaboni.it for an easy implementation).
== In theory ==
3 components:
- controller (Fraw): manage the configuration and the communication
intra-objects.
- model (various files in php calles "modules"): each module has a goal. Are
modules: Page, News, Guestbook, Session etc.
- view (various templates): when a template use a module, Fraw load it.
Module loading is dynamic, by use, not request: this increase the semplicity
and the speed. No standard layout (no phpNuke like), you can paint where you
wont when you wont. Some modules, like "Page" can be loaded by default; you
can redesign the structure with your plugins or personalize the standards.
Each module can be view like Smarty functions and blocks in the same moment
and in various modes.
Only view logic in template, no business logic or model logic.
<IMHO>
A template is born for render, not for manage.
</IMHO>
Sorry, in a single mail I wont go in depth.
== In pratice: a module ==
1- The user file 'index.php' build a Fraw object and say it the main template
('index.tpl').
2- Fraw configure the system, and load the 'index.tpl' template trough Smarty.
3- During the parsing, Smarty read this:
{module name="news.last" category="sport"}
<p><b>{$news.date}</b>{$news.content}</p>
4- Fraw load the module ('news.php') and return assign the value to the
template.
5- After, Smarty read this:
{/module}
6- Fraw check the nesting and unassing module variables.
---
The Page module read the $_GET['id'] and give the template name.
Is it useful for you?
Byez!
--
Davide Muzzarelli
www . dav - muz . net
--
Smarty General Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php