You are here: Re: [SMARTY] Seperation of Logic and Presentation « Smarty Templates Posts « IT news, forums, messages
Re: [SMARTY] Seperation of Logic and Presentation

Posted by Jamie Krasnoo on 07/30/05 01:20

I have a tendency to use the three tier method.

1. Database methods
2. Data and Business Interface
3. Display

Templates are always used and the business logic is never mixed in
with the display, ever. Things are just kept sane that way for me. I
do prefer to have separate files for separate areas instead if it all
falling in to one large file.After a while big files just get
convoluted and hard to maintain.

Jamie


On 7/29/05, Evan Wagner <webmast84@gmail.com> wrote:
> 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.
>
> Current Setup:
>
> 1 Parser file: index.php (Calls upon functions to run for pages via
> _GET variables)
>
> 1 Functions file: This file contains all functions used in the application
>
> 1 template file: index.tpl in the templates directory. This template
> file contains logic within itself such as {if $smarty.get.action
> =="page"} Do Page {/if}
>
> This current situation doesn't seem pragmatic to me.
>
> ALTERNATIVES:
>
> Alternative 1:
>
> 1 Parser file: index.php for example to handle the different _GET
> variables and tell smarty to parse a different template file for each
> _GET page.
>
> 1 Functions File: Contains all functions used in application
>
> Numerous Template Files: The parser file will call upon
> templates/page.tpl as defined in the parser file and for consistency
> of layout I would use {include header.tpl} and {include footer.tpl} in
> each page. This reduces the amount of logic in the template file and
> reduces size of template file.
>
> Alternative 2:
>
> 1 Parser file: index.php will handle all the _GET page logic to call
> upon correct functions via the different _GET variables.
>
> 1 Function file: Contains all functions of application
>
> 1 Primary layout template that will have logic in if such as this:
> {if $smarty.get.action =="page"} {include page.tpl} {/if}
> This still includes logic but reduces the complexity of the template
> by minimizing visible code.
>
>
> OVERVIEW:
>
> I theory I think Alternative1 is better than Alternative2 because it
> reduces the logic within the template. Basically keeps your template
> from doing as much logic as it's better to separate your logic and
> presentation.
>
> What do you guys think?
>
> --
> Smarty General Mailing List (http://smarty.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация