|
Hey Guys,
I seem to be having a problem turning off the child tree rendering for the phprenderer. Not sure what I'm doing wrong. Here's a couple of things I've tried from within the controller. Try One: --------------------------------------------- $renderer = $this->getServiceLocator()->get('ViewRenderer'); $renderer->setCanRenderTrees(false); --------------------------------------------- Try Two: --------------------------------------------- $view = new ViewModel(); $view->setOption('canRenderTrees', false); return $view; --------------------------------------------- I also thought about setting this in the config but not sure where to place it. Am I even close to how to turn these off? Thanks, Westin |
|
Administrator
|
-- Westin Shafer <[hidden email]> wrote
(on Sunday, 24 June 2012, 11:30 PM -0500): > I seem to be having a problem turning off the child tree rendering for > the phprenderer. Not sure what I'm doing wrong. It's actually disabled by default. canRenderTrees() is a hint from a renderer to Zend\View\View about how to render nested children. For renderers that implement TreeRendererInterface, the assumption is that you pass the view model to the renderer, and it will worry about rendering the hierarchy. In such a case, the value of canRenderTrees() is ignored. For renderers that do _not_ implement TreeRendererInterface, the flag is used to determine whether or not to render the children. If it's enabled, then Zend\View\View will render the children individually and aggregate the content into the current view model. Zend\View\Renderer\PhpRenderer implements TreeRendererInterface, which means the flag is ignored. Internally, it traverses children in the view model and renders them individually. What exactly are you trying to do? Are you trying to tell PhpRenderer not to render child models? > Here's a couple of things I've tried from within the controller. > > Try One: > --------------------------------------------- > $renderer = $this->getServiceLocator()->get('ViewRenderer'); > $renderer->setCanRenderTrees(false); > --------------------------------------------- > > Try Two: > --------------------------------------------- > $view = new ViewModel(); > $view->setOption('canRenderTrees', false); > return $view; > --------------------------------------------- > > I also thought about setting this in the config but not sure where to > place it. -- Matthew Weier O'Phinney Project Lead | [hidden email] Zend Framework | http://framework.zend.com/ PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc |
|
Matthew,
Thanks for the reply. Yes I'm just trying to keep the children from rendering. It looks like this may have been an error on my end. If I use "$children = $this->view_model()->getCurrent()->getChildren();" and echo out the "$children[0]->content" it has the last childs views content not the selected content. Now if I use "echo $this->render($children[0]);" it works fine. So I guess I just misunderstood what this->content really was. Thanks again, Westin On Mon, 2012-06-25 at 09:15 -0500, Matthew Weier O'Phinney wrote: > -- Westin Shafer <[hidden email]> wrote > (on Sunday, 24 June 2012, 11:30 PM -0500): > > I seem to be having a problem turning off the child tree rendering > for > > the phprenderer. Not sure what I'm doing wrong. > > It's actually disabled by default. > > canRenderTrees() is a hint from a renderer to Zend\View\View about how > to render nested children. > > For renderers that implement TreeRendererInterface, the assumption is > that you pass the view model to the renderer, and it will worry about > rendering the hierarchy. In such a case, the value of canRenderTrees() > is ignored. > > For renderers that do _not_ implement TreeRendererInterface, the flag > is > used to determine whether or not to render the children. If it's > enabled, then Zend\View\View will render the children individually and > aggregate the content into the current view model. > > Zend\View\Renderer\PhpRenderer implements TreeRendererInterface, which > means the flag is ignored. Internally, it traverses children in the > view > model and renders them individually. > > What exactly are you trying to do? Are you trying to tell PhpRenderer > not to render child models? > > > Here's a couple of things I've tried from within the controller. > > > > Try One: > > --------------------------------------------- > > $renderer = $this->getServiceLocator()->get('ViewRenderer'); > > $renderer->setCanRenderTrees(false); > > --------------------------------------------- > > > > Try Two: > > --------------------------------------------- > > $view = new ViewModel(); > > $view->setOption('canRenderTrees', false); > > return $view; > > --------------------------------------------- > > > > I also thought about setting this in the config but not sure where > to > > place it. > > -- > Matthew Weier O'Phinney > Project Lead | [hidden email] > Zend Framework | http://framework.zend.com/ > PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc > > > |
| Powered by Nabble | Edit this page |
