|
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 |
gurubob Smarty Rookie
Joined: 14 Jul 2003 Posts: 8 Location: Hertfordshire, UK
|
Posted: Fri Aug 08, 2003 5:53 pm Post subject: Feature Request: $smarty->template (string) |
|
|
Hi,
I've been dev'ing in Smarty lately (fab product ). I've been coding my apps along the lines of ...
Code: |
$s = new Smarty;
if (condition) {
$s->template = 'template_a.tpl';
} else {
$s->template = 'template_b.tpl';
}
$s->display($s->template);
|
I think it would be nice if all parameters for display() were optional and Smarty would use the template class variable if it was set. It makes my life easier. Just a thought.
Cheers,
- Bob - |
|
Back to top |
|
AZTEK Smarty Pro
Joined: 16 Apr 2003 Posts: 235 Location: Purdue University
|
Posted: Fri Aug 08, 2003 6:04 pm Post subject: |
|
|
You could easily extend the smarty class to do that just add a member variable and create your own display something like [php:1:a399c5313c]<?php
class MySmarty extends Smarty {
var $template;
function MySmarty() {
$this->template = "default.tpl";
}
function display() {
parent::display($this->template);
}
}
?>[/php:1:a399c5313c]thats just a quick write up I didnt test it so shoot me if it doesnt work. Then instead of $s = new Smarty; do $s = new MySmarty; _________________ "Imagine a school with children that can read and write, but with teachers who cannot, and you have a metaphor of the Information Age in which we live." -Peter Cochrane |
|
Back to top |
|
gurubob Smarty Rookie
Joined: 14 Jul 2003 Posts: 8 Location: Hertfordshire, UK
|
Posted: Fri Aug 08, 2003 7:10 pm Post subject: |
|
|
Hey Aztek,
Thanks for the code example - I haven't really got around to extending existing classes in PHP yet but I might just have to do that.
Cheers! |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Fri Aug 08, 2003 7:17 pm Post subject: |
|
|
Yes, I heartily agree with Aztek--conveniences such as that are best left to a custom class which inherits Smarty.
off-topic: I think I am biased by the way I use Smarty, but in my mind, even display() should be left out of the core. You'd be forced to use fetch() instead, making it clear that Smarty provides only transformation services and not delivery services. That, of course, is only my opinion but since you typically require a request broker when using Smarty, it seems like a reasonable choice to me and permits for better delineated pipelining of the production chain. Some may suggest an integrated front controller but I still think there is merit in keeping the core compact and single-purposed. |
|
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
|