Yes Matthew. Thank you for telling me that I've wasted 2 days of my life for
this.

Just in case or might be a feedback; The last added path is supposed to be
used for rendering. But if there the default view folder exists, it still
looks and renders it first. (ZF 1.5.1)

part of $view dump;
[script] => Array
(
[0] => .\application\views\scripts\
[1] => .\templates\default\scripts\
)

So it is done with using viewRenderer but remember to remove
application/view (or whatever) folder to work as we want. Adding another
base (or script) paths works as expected.

Cheers and thanks again.



2008/4/13, Matthew Weier O'Phinney <[EMAIL PROTECTED]>:
>
> -- kirpit <[EMAIL PROTECTED]> wrote
> (on Sunday, 13 April 2008, 03:22 PM +0300):
>
> > Hi, im just a newbie with ZF.
> >
> > I just wanted to move view folder to another path. It seems it can be
> done with
> > addBasePath() but here comes the questions.
> >
> > It does work if i add "$this->view->addBasePath..." in the current
> > action but isn't it stupid to add this line in every action?
> > So i've tried $this->view->addBasePath... in controller's init()
> >  function which works too. But honestly, this is not the correct way
> neither.
> >
> > Suppose i prepared my $view object with all the paths helpers etc. and
> put it
> > in registry. Then calling it with:
> >
> > public function init() {
> > this->view = Zend_Registry::get('view');
> > }
> >
> > Which simply does not work. Im trying to do that around 2 days and i
> gave up.
> > Everything looks ok in action:
> > public function indexAction() {
> >   print_r($this->view);
> > }
> > gives the correct dump of view paths but it just NOT working.
> >
> > Also i think it's stupid to assign view object from registry in
> > every controller's init. Don't we have some mothod like;
> > $controller->setParam('defaultViewObject', $view);
> > we can do it in bootstrap only once after setting everything about
> $view?
>
>
> The ViewRenderer contains the view instance used for auto-rendering and
> used by Zend_Layout by default. The easiest way to setup your view
> object with your own settings is to create it in the bootstrap or an
> early-running plugin and register it with the ViewRenderer:
>
>     $view = new Zend_View();
>     $view->addScriptPath('path/to/default/scripts'); // or addBasePath(),
> if you prefer
>     $viewRenderer =
> Zend_Controller_Action_HelperBroker:;getStaticHelper('viewRenderer');
>     $viewRenderer->setView($view);
>
> Once you've done this, the paths you set will be available throughout
> your application.
>
>
> --
> Matthew Weier O'Phinney
> Software Architect       | [EMAIL PROTECTED]
> Zend - The PHP Company   | http://www.zend.com/
>

Reply via email to