Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Moving controller calls into template

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Tips and Tricks
View previous topic :: View next topic  
Author Message
Dice
Smarty Rookie


Joined: 11 May 2010
Posts: 14

PostPosted: Wed Jun 27, 2012 12:44 pm    Post subject: Moving controller calls into template Reply with quote

I am aware that smarty advertises the separation between logic and style though i had an idea which could technically improve a system i am creating.

Many systems share the same controller for all templates which includes calls to the database and is based on things like getting the latest 10 articles etc. So what if i had 2 totally different templates, where one wanted to pull 5 and the other wanted to pull 10. The controller code would have to change based on what skin is being run. Since I don't want people touching the controllers i would prefer people playing in the templates. So what i came up with was this idea.

1. call the function as a smarty function:
{get_articles limit=10 published=true category=news result=articles}
2. After the item is called we can then foreach the result which is $articles.

Is this a good idea to keep people out of the controllers? How would i further extend this idea to make it even better?

EDIT: I believe this is what i am trying to achieve

http://www.smarty.net/docs/en/tips.componentized.templates.tpl

I guess this topic isn't so useful anymore but i may leave it for other people that are interested.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Tips and Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP