|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
SordidWarrior Smarty Rookie
Joined: 03 Sep 2004 Posts: 6 Location: Paris, France
|
Posted: Fri Sep 10, 2004 12:55 am Post subject: plugins or not plugins |
|
|
Hi all
I am currently moving my web site to smarty; while doing the move, I had some issues about when I should write plugins, and when I should not.
For example, I wanted to be able to add a summary for some pages. The summary is made of data loaded from the database, so I created a "my_summary" plugin function, that connects to the database, load the chapters information in an array, and then displays the data in a template. So, I just have to write:
[php:1:db2f9e0635]<?php
$smarty->assign('chapter', 1;
?>[/php:1:db2f9e0635]
And to include summary of the chapter:
Code: | {my_summary template='summary.tpl' chapter=$chapter} |
Is it a good use of plug-in, or should I do it another way?
Another example, I had on my old web site some images that were displayed when an image name was provided. This allowed me to easily add some images at some specific locations.
To keep workload to a minimum, for the move, I created a plugin that looks if the specific file exists, and then includes the image. This way, I can just call the plugin in the template where I want to have an image sometimes displayed.
Is it good practice? How will the template compilation work with this kind of plugins? Would it force re-compilation of the template, or would it be OK?
Thanks for the advices (and for smarty ) _________________ Vincent Vandemeulebrouck
Coding expert, smarty newbie
http://www.leguerriersorde.com/ |
|
Back to top |
|
|
|
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
|