[Solar-talk] View, call helpers after _render() ?
Matt M.
goodieboy at gmail.com
Fri Nov 3 06:16:21 PST 2006
I'll explain a littele more here sorry!
I want to be able to wrap a layout around a view. I'm experimenting with
doing this in my templates. The page controller is expecting to get the
rendered results back and send it to either a single layout template, or
print the output.
I want to intercept both of those scenarios and wrap the view with a layout.
The only way I could think of doing this is to use a helper. It's called
Helper_Layout. You pass in the name of a layout to use like:
$this->layout('document')
That simply sets the Helper_Layout::$_name property to 'document'. If I want
all of the content in the view (calling the layout helper) to go to the
layout_content placholder inside of the 'document' layout... I have to
capture that output. That can only be done after the entire view has been
rendered. So, I could simply print the layout result by calling
$this->layout().
But I want to have that happen automatically.
To do that... I'd need an opportunity to capture the content from the view,
pass it into the document template and then echo out the rendered 'document'
layout...
Whew... does that make sense now? Django (
http://www.djangoproject.com/documentation/templates/) has something very
similar using "extends".
Here is my layout helper.. and the method that would be called if there was
a postViewRender() method called on the helpers from the View...
class Lima_View_Helper_Layout extends Solar_View_Helper {
protected $_template;
// must call: <?php echo $this->layout() ?> at end of view template...
function layout($name=NULL){
if( $name )
{
$this->_template = $name;
}
else
{
$view = $this->_view;
$view->addTemplatePath( 'Layout/' );
return $view->fetch( $this->_template . '.php' );
}
}
/* wouldn't have to call: <?php echo $this->layout() ?> at end of view
template...
public function postViewRender()
{
$view = $this->_view;
$view->addTemplatePath( 'Layout/' );
echo $view->fetch( $this->_template . '.php' );
}
*/
}
Matt
On 11/3/06, Rodrigo Moraes <rodrigo.moraes at gmail.com> wrote:
>
> On 11/3/06, Matt M. <goodieboy at gmail.com> wrote:
> > Hi,
> > Works like:
> >
> > <?php $this->layout('document') ?>
> > // here i set slots in the ''document" template
> > // now I'd like it to render by itself...
> > // or I could do:
> > <?php echo $this->layout() ?>
> >
> > but It'd be nice to have it done automatically. It needs to happen after
> all
> > of the contents of the template have been rendererd. Does that make
> sense?
>
> I don't understand your example. You want to set dynamic slots in a
> template and render them independently? There is some ways to do this:
> using partials to have a separate scope or including a template
> dynamically.
>
> rodrigo
> _______________________________________________
> solar-talk mailing list
> solar-talk at lists.solarphp.com
> http://mail.killersoft.com/mailman/listinfo/solar-talk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.killersoft.com/pipermail/solar-talk/attachments/20061103/e8051c35/attachment.html
More information about the solar-talk
mailing list