[Solar-talk] Solar_View
Matt M.
goodieboy at gmail.com
Sat Oct 14 08:36:11 PDT 2006
Hi,
Before I get started... is there a better place to post code? I'd like this
to be considered for implementation to the source :)
I've noticed that the view class does not hold on the the template path
value. Everytime you render you have to tell it which template to use, which
means you can't pass it around to other objects and render without the other
objects knowing which template to use. I have a controller framework that
allows child controllers to pass their responses (Solar_View) to their
parent, but then the parent needs to know what template to use... which does
not work.
It's a simple fix...
We need to add a new method called Solar_View::setTemplate($name){}
/**
* Set the template file
*/
public setTemplate($name){
$this->_template_file = $this->template($name);
}
Now, change the Solar_View::fetch() and Solar_View::display() functions a
bit... allow the $name to be empty, which will use the currently set
$this->_template_file
/**
*
*/
public function display($name=NULL)
{
echo $this->fetch($name);
}
/**
*
*/
public function fetch($name=NULL)
{
$name = empty($name) ? $this->_template_file : $this->template($name);
// save externally and unset from local scope
$this->_template_file = $name;
unset($name);
// run the template
ob_start();
require $this->_template_file;
return ob_get_clean();
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.killersoft.com/pipermail/solar-talk/attachments/20061014/d21bc0a8/attachment.htm
More information about the solar-talk
mailing list