I am currently using:

$this->view = Zend_Layout::getMvcInstance()->getView();
        $this->view->doctype( Zend_Registry::get('config')->layout->doctype
);
        $this->view->setScriptPath( MODULE_PATH . 'views/scripts/' );
        $this->viewRenderer = $this->_helper->getHelper('viewRenderer');
        $this->viewRenderer->setView($this->view)->setViewBasePathSpec(
MODULE_PATH . 'views/scripts/'
)->setViewScriptPathSpec(':controller/:action.phtml');

Then i am doing inside a controller:

$this->viewRenderer->render('index');

then it looks for the script under: MODULE_PATH .
'views/scripts/:controller/:action.phtml

Now, First is there a way of doing the same thing, without using the
ViewRenderer helper? I mean doing:
$this->view = Zend_Layout::getMvcInstance()->getView()->setViewBasePathSpec(
MODULE_PATH . 'views/scripts/'
)->setViewScriptPathSpec(':controller/:action.phtml');
and then using:

$this->viewRenderer->render('index');

and it will do the same thing? i did some tests and well it's not possible
unless i am missing something.

Second how can i use the method
$this->viewRenderer->render('index');

to return the content instead of echoing it out? currently i used
$this->view->Partial(....) instead but the thing with it that i need to
specify the directory and the extension of the file to render and additional
parameters as a second array argument in it so it comes up to something like
this:

return $this->view->partial('tools/setting-group-render-setting.phtml',
array( 'lang' => $this->lang, 'public_url' => $this->public_url, 'rows' =>
$r));

instead of just his:

return $this->viewRenderer->render('setting_group_render_setting');

which is a lot easier if later on i will change the controller name and/or
the suffix of the html files. can the render function return the content
instead of echoing it out?

Thanks.




-- 
Vincent Gabriel.
Lead Developer, Senior Support.
Zend Certified Engineer.

Reply via email to