Re: [fw-general] Changing view path in bootstrap
Not the exact coding you told me but here you go the code which renders default path: http://rapidshare.com/files/107904425/test.rar.html If i remove or change name of default view folder it renders as expected. And the phpinfo() of my system. Zend Framework version is 1.5.1 http://rapidshare.com/files/107904427/phpinfo.html Have a nice day. 2008/4/15, Matthew Weier O'Phinney <[EMAIL PROTECTED]>: > > -- Serkan Kibritoglu <[EMAIL PROTECTED]> wrote > > (on Tuesday, 15 April 2008, 06:05 PM +0300): > > > I think I could not express myself very well. Let's get to beginning > > with a new clean $view object: > > > > I create the $view. So it should have only one base path which is > default. > > > > Then I simply add my custom base path. Which is second added. Now this > > custom base path becomes "last in" and should be "first out" isnt it? > > > > When i execute, i see it renders the > > default, first inned base path. So tell me is it FIFO or LIFO? > > Yes the answer is FIFO. > > And I want it to work as expected as LIFO. Nothing extra. Nothing > default. The > > path i have added last. > > > First off, don't look at how the path data is stored in Zend_View; it's > irrelevant. Look instead at the behavior. The behavior is documented and > tested as a LIFO stack. > > You're claiming that you're not seeing this behavior, that instead > you're seeing a FIFO behavior, but since you don't provide any code or > scripts to recreate it, I cannot verify. > > Here is what I've done to attempt to recreate what you're describing. > > First, a directory tree: > > test.php > views/ > test1/ > index.phtml > test2/ > index.phtml > > In views/test1/index.phtml and views/test2/index.phtml, I have the > following: > > > > In test.php: > > $view = new Zend_View(); > $view->addScriptPath('views/test1/'); > $view->addScriptPath('views/test2/'); > echo $view->render('index.phtml'); > > The actual output, as well as the expected result, is a string > containing: > > views/test2/index.phtml > > If you are getting different results, I need to know the ZF version, PHP > version, and OS you're using. If the above does not depict what you're > doing, please send in *code* -- NOT a description -- that reproduces the > behavior you're observing so I can test. > > > > > 2008/4/14, Matthew Weier O'Phinney <[EMAIL PROTECTED]>: > > > > -- David Rogers <[EMAIL PROTECTED]> wrote > > (on Monday, 14 April 2008, 10:49 AM -0400): > > > > > Well, the issue here is that kirpit may not be using the > > > array_(un)shift() functions to get his paths on the stack, > initially, > > > like ZF does natively. > > > > > > No, he is, because he's using Zend_View. His examples clearly show > this, > > too -- he simply wants a different behavior -- a FIFO stack. > > > > > > > The use of those functions for the LIFO stack > > > pattern is fairly well understood by many of us, but it's kinda > > > hackish... Like many things involving PHP and arrays. :D > > > > > > On Apr 14, 2008, at 8:05 AM, Matthew Weier O'Phinney wrote: > > > > > >> -- kirpit <[EMAIL PROTECTED]> wrote > > >> (on Monday, 14 April 2008, 10:12 AM +0300): > > >>> I disagree. Because the first on the stack which means index > zero to > > >>> be executed. > > >> > > >> We use array_unshift() to push new paths to the top of the stack, > > >> which > > >> means the *newest* path added to the stack is executed first. > This is > > >> the very definition of a LIFO stack, which is what Zend_View > > >> implements. > > >> > > >>> When I add 2 base paths: > > >>> $view->addBasePath(realpath('./templates/default/')); > > >>> $view->addBasePath(realpath('./templates/fashion/')); > > >>> > > >>> Script paths becomes like: > > >>> [0] => E:\htdocs\page\application\views\scripts\ > > >> > > >> The above is added by the ViewRenderer when a controller is > invoked. > > >> > > >>> [1] => E:\htdocs\page\templates\fashion\scripts\ > > >>> [2] => E:\htdocs\page\templates\default\scripts\ > > >>> > > >>> And exactly the index 0 is executed. If not exist it looks for > index > > >>> 1... > > >> > > >> Which is exactly as it is designed. Script paths added later get > > >> searched first, script paths added earlier get searched last -- > again, > > >> LIFO. This is so that you can have later script paths override > > >> defaults. > > >> If we did this as a FIFO stack, you would never be able to > override > > >> default paths with local paths. > > >> > > >>> I think the script paths should become like: > > >>> [0] => E:\htdocs\page\templates\fashion\scripts\ > > >>> [1] => E:\htdocs\page\templates\default\scripts\ > > >>> [2] => E:\htdocs\page\application\views\scripts\ > > >> > > >> Not going to happen, as it breaks the design goals and
Re: [fw-general] Changing view path in bootstrap
-- Serkan Kibritoglu <[EMAIL PROTECTED]> wrote (on Tuesday, 15 April 2008, 06:05 PM +0300): > I think I could not express myself very well. Let's get to beginning > with a new clean $view object: > > I create the $view. So it should have only one base path which is default. > > Then I simply add my custom base path. Which is second added. Now this > custom base path becomes "last in" and should be "first out" isnt it? > > When i execute, i see it renders the > default, first inned base path. So tell me is it FIFO or LIFO? > Yes the answer is FIFO. > And I want it to work as expected as LIFO. Nothing extra. Nothing default. The > path i have added last. First off, don't look at how the path data is stored in Zend_View; it's irrelevant. Look instead at the behavior. The behavior is documented and tested as a LIFO stack. You're claiming that you're not seeing this behavior, that instead you're seeing a FIFO behavior, but since you don't provide any code or scripts to recreate it, I cannot verify. Here is what I've done to attempt to recreate what you're describing. First, a directory tree: test.php views/ test1/ index.phtml test2/ index.phtml In views/test1/index.phtml and views/test2/index.phtml, I have the following: In test.php: $view = new Zend_View(); $view->addScriptPath('views/test1/'); $view->addScriptPath('views/test2/'); echo $view->render('index.phtml'); The actual output, as well as the expected result, is a string containing: views/test2/index.phtml If you are getting different results, I need to know the ZF version, PHP version, and OS you're using. If the above does not depict what you're doing, please send in *code* -- NOT a description -- that reproduces the behavior you're observing so I can test. > 2008/4/14, Matthew Weier O'Phinney <[EMAIL PROTECTED]>: > > -- David Rogers <[EMAIL PROTECTED]> wrote > (on Monday, 14 April 2008, 10:49 AM -0400): > > > Well, the issue here is that kirpit may not be using the > > array_(un)shift() functions to get his paths on the stack, initially, > > like ZF does natively. > > > No, he is, because he's using Zend_View. His examples clearly show this, > too -- he simply wants a different behavior -- a FIFO stack. > > > > The use of those functions for the LIFO stack > > pattern is fairly well understood by many of us, but it's kinda > > hackish... Like many things involving PHP and arrays. :D > > > > On Apr 14, 2008, at 8:05 AM, Matthew Weier O'Phinney wrote: > > > >> -- kirpit <[EMAIL PROTECTED]> wrote > >> (on Monday, 14 April 2008, 10:12 AM +0300): > >>> I disagree. Because the first on the stack which means index zero to > >>> be executed. > >> > >> We use array_unshift() to push new paths to the top of the stack, > >> which > >> means the *newest* path added to the stack is executed first. This is > >> the very definition of a LIFO stack, which is what Zend_View > >> implements. > >> > >>> When I add 2 base paths: > >>> $view->addBasePath(realpath('./templates/default/')); > >>> $view->addBasePath(realpath('./templates/fashion/')); > >>> > >>> Script paths becomes like: > >>> [0] => E:\htdocs\page\application\views\scripts\ > >> > >> The above is added by the ViewRenderer when a controller is invoked. > >> > >>> [1] => E:\htdocs\page\templates\fashion\scripts\ > >>> [2] => E:\htdocs\page\templates\default\scripts\ > >>> > >>> And exactly the index 0 is executed. If not exist it looks for index > >>> 1... > >> > >> Which is exactly as it is designed. Script paths added later get > >> searched first, script paths added earlier get searched last -- again, > >> LIFO. This is so that you can have later script paths override > >> defaults. > >> If we did this as a FIFO stack, you would never be able to override > >> default paths with local paths. > >> > >>> I think the script paths should become like: > >>> [0] => E:\htdocs\page\templates\fashion\scripts\ > >>> [1] => E:\htdocs\page\templates\default\scripts\ > >>> [2] => E:\htdocs\page\application\views\scripts\ > >> > >> Not going to happen, as it breaks the design goals and implementation > >> of > >> Zend_View. > >> > >> If you want that behavior, you will need to subclass Zend_View > >> yourself > >> to do so. > >> > >> > >>> 2008/4/14, Matthew Weier O'Phinney <[EMAIL PROTECTED]>: > >>> > >>>-- Serkan Kibritoglu <[EMAIL PROTECTED]> wrote > >>>(on Sunday, 13 April 2008, 10:47 PM +0300): > 2008/4/13, Matthew Weier O'Phinney <[EMAIL PROTECTED]>: > -- Serkan Kibritoglu <[EMAIL PROTECTED]> wrote > (on Sunday, 13 April 2008, 09:47 PM +0300): > > Just in case or might be a feedback; The last added path is > > supp
Re: [fw-general] Changing view path in bootstrap
I think I could not express myself very well. Let's get to beginning with a new clean $view object: I create the $view. So it should have only one base path which is default. Then I simply add my custom base path. Which is second added. Now this custom base path becomes "last in" and should be "first out" isnt it? When i execute, i see it renders the default, first inned base path. So tell me is it FIFO or LIFO? Yes the answer is FIFO. And I want it to work as expected as LIFO. Nothing extra. Nothing default. The path i have added last. 2008/4/14, Matthew Weier O'Phinney <[EMAIL PROTECTED]>: > > -- David Rogers <[EMAIL PROTECTED]> wrote > (on Monday, 14 April 2008, 10:49 AM -0400): > > > Well, the issue here is that kirpit may not be using the > > array_(un)shift() functions to get his paths on the stack, initially, > > like ZF does natively. > > > No, he is, because he's using Zend_View. His examples clearly show this, > too -- he simply wants a different behavior -- a FIFO stack. > > > > The use of those functions for the LIFO stack > > pattern is fairly well understood by many of us, but it's kinda > > hackish... Like many things involving PHP and arrays. :D > > > > On Apr 14, 2008, at 8:05 AM, Matthew Weier O'Phinney wrote: > > > >> -- kirpit <[EMAIL PROTECTED]> wrote > >> (on Monday, 14 April 2008, 10:12 AM +0300): > >>> I disagree. Because the first on the stack which means index zero to > >>> be executed. > >> > >> We use array_unshift() to push new paths to the top of the stack, > >> which > >> means the *newest* path added to the stack is executed first. This is > >> the very definition of a LIFO stack, which is what Zend_View > >> implements. > >> > >>> When I add 2 base paths: > >>> $view->addBasePath(realpath('./templates/default/')); > >>> $view->addBasePath(realpath('./templates/fashion/')); > >>> > >>> Script paths becomes like: > >>> [0] => E:\htdocs\page\application\views\scripts\ > >> > >> The above is added by the ViewRenderer when a controller is invoked. > >> > >>> [1] => E:\htdocs\page\templates\fashion\scripts\ > >>> [2] => E:\htdocs\page\templates\default\scripts\ > >>> > >>> And exactly the index 0 is executed. If not exist it looks for index > >>> 1... > >> > >> Which is exactly as it is designed. Script paths added later get > >> searched first, script paths added earlier get searched last -- again, > >> LIFO. This is so that you can have later script paths override > >> defaults. > >> If we did this as a FIFO stack, you would never be able to override > >> default paths with local paths. > >> > >>> I think the script paths should become like: > >>> [0] => E:\htdocs\page\templates\fashion\scripts\ > >>> [1] => E:\htdocs\page\templates\default\scripts\ > >>> [2] => E:\htdocs\page\application\views\scripts\ > >> > >> Not going to happen, as it breaks the design goals and implementation > >> of > >> Zend_View. > >> > >> If you want that behavior, you will need to subclass Zend_View > >> yourself > >> to do so. > >> > >> > >>> 2008/4/14, Matthew Weier O'Phinney <[EMAIL PROTECTED]>: > >>> > >>>-- Serkan Kibritoglu <[EMAIL PROTECTED]> wrote > >>>(on Sunday, 13 April 2008, 10:47 PM +0300): > 2008/4/13, Matthew Weier O'Phinney <[EMAIL PROTECTED]>: > -- Serkan Kibritoglu <[EMAIL PROTECTED]> wrote > (on Sunday, 13 April 2008, 09:47 PM +0300): > > 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) > > > Hmmm... I haven't noticed that behavior at all. Can you show a short > reproduce script that reproduces the issue? > > Here is the bootstrap: > > $view = new Zend_View(); > $view->addBasePath(realpath('./templates/default/')); > //$view->addBasePath(realpath('./templates/fashion/')); > /** > * Use our $view as renderer > */ > Zend_Controller_Action_HelperBroker > ::getStaticHelper('viewRenderer')-> > >>>setView > ($view); > > > > Here goes the print_r($this->view); in an empty action. > Zend_View Object > ( > [_path:private] => Array > ( > [script] => Array > ( > [0] => C:\xampp\htdocs\vpage\application\views\scripts\ > [1] => C:\xampp\htdocs\vpage\templates\default\scripts\ > ) > >>> > >>>This is correct. 'templates/default/scripts' is the first added > >>> path, > >>>and is therefor the last on the stack to be executed. No bug here. > >>> > >>>If you don't trust this, put an index.phtml in each directory with > >>>different contents, and see which one gets rendered (hint, it > >>> will be > >>>the one in application/views/scripts/). > >>> > >>> > >>>-- > >>>Matthew Weier O'Phinney > >>>Software Architect | [EMAIL PROTECTED] > >>>Zend - The PHP Company | http://www.zend.com/ > >>> > >>> > >>
Re: [fw-general] Changing view path in bootstrap
-- David Rogers <[EMAIL PROTECTED]> wrote (on Monday, 14 April 2008, 10:49 AM -0400): > Well, the issue here is that kirpit may not be using the > array_(un)shift() functions to get his paths on the stack, initially, > like ZF does natively. No, he is, because he's using Zend_View. His examples clearly show this, too -- he simply wants a different behavior -- a FIFO stack. > The use of those functions for the LIFO stack > pattern is fairly well understood by many of us, but it's kinda > hackish... Like many things involving PHP and arrays. :D > > On Apr 14, 2008, at 8:05 AM, Matthew Weier O'Phinney wrote: > >> -- kirpit <[EMAIL PROTECTED]> wrote >> (on Monday, 14 April 2008, 10:12 AM +0300): >>> I disagree. Because the first on the stack which means index zero to >>> be executed. >> >> We use array_unshift() to push new paths to the top of the stack, >> which >> means the *newest* path added to the stack is executed first. This is >> the very definition of a LIFO stack, which is what Zend_View >> implements. >> >>> When I add 2 base paths: >>> $view->addBasePath(realpath('./templates/default/')); >>> $view->addBasePath(realpath('./templates/fashion/')); >>> >>> Script paths becomes like: >>> [0] => E:\htdocs\page\application\views\scripts\ >> >> The above is added by the ViewRenderer when a controller is invoked. >> >>> [1] => E:\htdocs\page\templates\fashion\scripts\ >>> [2] => E:\htdocs\page\templates\default\scripts\ >>> >>> And exactly the index 0 is executed. If not exist it looks for index >>> 1... >> >> Which is exactly as it is designed. Script paths added later get >> searched first, script paths added earlier get searched last -- again, >> LIFO. This is so that you can have later script paths override >> defaults. >> If we did this as a FIFO stack, you would never be able to override >> default paths with local paths. >> >>> I think the script paths should become like: >>> [0] => E:\htdocs\page\templates\fashion\scripts\ >>> [1] => E:\htdocs\page\templates\default\scripts\ >>> [2] => E:\htdocs\page\application\views\scripts\ >> >> Not going to happen, as it breaks the design goals and implementation >> of >> Zend_View. >> >> If you want that behavior, you will need to subclass Zend_View >> yourself >> to do so. >> >> >>> 2008/4/14, Matthew Weier O'Phinney <[EMAIL PROTECTED]>: >>> >>>-- Serkan Kibritoglu <[EMAIL PROTECTED]> wrote >>>(on Sunday, 13 April 2008, 10:47 PM +0300): 2008/4/13, Matthew Weier O'Phinney <[EMAIL PROTECTED]>: -- Serkan Kibritoglu <[EMAIL PROTECTED]> wrote (on Sunday, 13 April 2008, 09:47 PM +0300): > 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) Hmmm... I haven't noticed that behavior at all. Can you show a short reproduce script that reproduces the issue? Here is the bootstrap: $view = new Zend_View(); $view->addBasePath(realpath('./templates/default/')); //$view->addBasePath(realpath('./templates/fashion/')); /** * Use our $view as renderer */ Zend_Controller_Action_HelperBroker ::getStaticHelper('viewRenderer')-> >>>setView ($view); Here goes the print_r($this->view); in an empty action. Zend_View Object ( [_path:private] => Array ( [script] => Array ( [0] => C:\xampp\htdocs\vpage\application\views\scripts\ [1] => C:\xampp\htdocs\vpage\templates\default\scripts\ ) >>> >>>This is correct. 'templates/default/scripts' is the first added >>> path, >>>and is therefor the last on the stack to be executed. No bug here. >>> >>>If you don't trust this, put an index.phtml in each directory with >>>different contents, and see which one gets rendered (hint, it >>> will be >>>the one in application/views/scripts/). >>> >>> >>>-- >>>Matthew Weier O'Phinney >>>Software Architect | [EMAIL PROTECTED] >>>Zend - The PHP Company | http://www.zend.com/ >>> >>> >> >> -- >> Matthew Weier O'Phinney >> Software Architect | [EMAIL PROTECTED] >> Zend - The PHP Company | http://www.zend.com/ > -- Matthew Weier O'Phinney Software Architect | [EMAIL PROTECTED] Zend - The PHP Company | http://www.zend.com/
Re: [fw-general] Changing view path in bootstrap
Well, the issue here is that kirpit may not be using the array_(un)shift() functions to get his paths on the stack, initially, like ZF does natively. The use of those functions for the LIFO stack pattern is fairly well understood by many of us, but it's kinda hackish... Like many things involving PHP and arrays. :D On Apr 14, 2008, at 8:05 AM, Matthew Weier O'Phinney wrote: -- kirpit <[EMAIL PROTECTED]> wrote (on Monday, 14 April 2008, 10:12 AM +0300): I disagree. Because the first on the stack which means index zero to be executed. We use array_unshift() to push new paths to the top of the stack, which means the *newest* path added to the stack is executed first. This is the very definition of a LIFO stack, which is what Zend_View implements. When I add 2 base paths: $view->addBasePath(realpath('./templates/default/')); $view->addBasePath(realpath('./templates/fashion/')); Script paths becomes like: [0] => E:\htdocs\page\application\views\scripts\ The above is added by the ViewRenderer when a controller is invoked. [1] => E:\htdocs\page\templates\fashion\scripts\ [2] => E:\htdocs\page\templates\default\scripts\ And exactly the index 0 is executed. If not exist it looks for index 1... Which is exactly as it is designed. Script paths added later get searched first, script paths added earlier get searched last -- again, LIFO. This is so that you can have later script paths override defaults. If we did this as a FIFO stack, you would never be able to override default paths with local paths. I think the script paths should become like: [0] => E:\htdocs\page\templates\fashion\scripts\ [1] => E:\htdocs\page\templates\default\scripts\ [2] => E:\htdocs\page\application\views\scripts\ Not going to happen, as it breaks the design goals and implementation of Zend_View. If you want that behavior, you will need to subclass Zend_View yourself to do so. 2008/4/14, Matthew Weier O'Phinney <[EMAIL PROTECTED]>: -- Serkan Kibritoglu <[EMAIL PROTECTED]> wrote (on Sunday, 13 April 2008, 10:47 PM +0300): 2008/4/13, Matthew Weier O'Phinney <[EMAIL PROTECTED]>: -- Serkan Kibritoglu <[EMAIL PROTECTED]> wrote (on Sunday, 13 April 2008, 09:47 PM +0300): 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) Hmmm... I haven't noticed that behavior at all. Can you show a short reproduce script that reproduces the issue? Here is the bootstrap: $view = new Zend_View(); $view->addBasePath(realpath('./templates/default/')); //$view->addBasePath(realpath('./templates/fashion/')); /** * Use our $view as renderer */ Zend_Controller_Action_HelperBroker ::getStaticHelper('viewRenderer')-> setView ($view); Here goes the print_r($this->view); in an empty action. Zend_View Object ( [_path:private] => Array ( [script] => Array ( [0] => C:\xampp\htdocs\vpage\application\views\scripts\ [1] => C:\xampp\htdocs\vpage\templates\default\scripts\ ) This is correct. 'templates/default/scripts' is the first added path, and is therefor the last on the stack to be executed. No bug here. If you don't trust this, put an index.phtml in each directory with different contents, and see which one gets rendered (hint, it will be the one in application/views/scripts/). -- Matthew Weier O'Phinney Software Architect | [EMAIL PROTECTED] Zend - The PHP Company | http://www.zend.com/ -- Matthew Weier O'Phinney Software Architect | [EMAIL PROTECTED] Zend - The PHP Company | http://www.zend.com/
Re: [fw-general] Changing view path in bootstrap
-- kirpit <[EMAIL PROTECTED]> wrote (on Monday, 14 April 2008, 10:12 AM +0300): > I disagree. Because the first on the stack which means index zero to > be executed. We use array_unshift() to push new paths to the top of the stack, which means the *newest* path added to the stack is executed first. This is the very definition of a LIFO stack, which is what Zend_View implements. > When I add 2 base paths: > $view->addBasePath(realpath('./templates/default/')); > $view->addBasePath(realpath('./templates/fashion/')); > > Script paths becomes like: > [0] => E:\htdocs\page\application\views\scripts\ The above is added by the ViewRenderer when a controller is invoked. > [1] => E:\htdocs\page\templates\fashion\scripts\ > [2] => E:\htdocs\page\templates\default\scripts\ > > And exactly the index 0 is executed. If not exist it looks for index > 1... Which is exactly as it is designed. Script paths added later get searched first, script paths added earlier get searched last -- again, LIFO. This is so that you can have later script paths override defaults. If we did this as a FIFO stack, you would never be able to override default paths with local paths. > I think the script paths should become like: > [0] => E:\htdocs\page\templates\fashion\scripts\ > [1] => E:\htdocs\page\templates\default\scripts\ > [2] => E:\htdocs\page\application\views\scripts\ Not going to happen, as it breaks the design goals and implementation of Zend_View. If you want that behavior, you will need to subclass Zend_View yourself to do so. > 2008/4/14, Matthew Weier O'Phinney <[EMAIL PROTECTED]>: > > -- Serkan Kibritoglu <[EMAIL PROTECTED]> wrote > (on Sunday, 13 April 2008, 10:47 PM +0300): > > 2008/4/13, Matthew Weier O'Phinney <[EMAIL PROTECTED]>: > > -- Serkan Kibritoglu <[EMAIL PROTECTED]> wrote > > (on Sunday, 13 April 2008, 09:47 PM +0300): > > > 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) > > > > > > Hmmm... I haven't noticed that behavior at all. Can you show a short > > reproduce script that reproduces the issue? > > > > Here is the bootstrap: > > > > $view = new Zend_View(); > > $view->addBasePath(realpath('./templates/default/')); > > //$view->addBasePath(realpath('./templates/fashion/')); > > /** > > * Use our $view as renderer > > */ > > Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')-> > setView > > ($view); > > > > > > > > Here goes the print_r($this->view); in an empty action. > > Zend_View Object > > ( > > [_path:private] => Array > > ( > > [script] => Array > > ( > > [0] => C:\xampp\htdocs\vpage\application\views\scripts\ > > [1] => C:\xampp\htdocs\vpage\templates\default\scripts\ > > ) > > This is correct. 'templates/default/scripts' is the first added path, > and is therefor the last on the stack to be executed. No bug here. > > If you don't trust this, put an index.phtml in each directory with > different contents, and see which one gets rendered (hint, it will be > the one in application/views/scripts/). > > > -- > Matthew Weier O'Phinney > Software Architect | [EMAIL PROTECTED] > Zend - The PHP Company | http://www.zend.com/ > > -- Matthew Weier O'Phinney Software Architect | [EMAIL PROTECTED] Zend - The PHP Company | http://www.zend.com/
Re: [fw-general] Changing view path in bootstrap
I disagree. Because the first on the stack which means index zero to be executed. When I add 2 base paths: $view->addBasePath(realpath('./templates/default/')); $view->addBasePath(realpath('./templates/fashion/')); Script paths becomes like: [0] => E:\htdocs\page\application\views\scripts\ [1] => E:\htdocs\page\templates\fashion\scripts\ [2] => E:\htdocs\page\templates\default\scripts\ And exactly the index 0 is executed. If not exist it looks for index 1... I think the script paths should become like: [0] => E:\htdocs\page\templates\fashion\scripts\ [1] => E:\htdocs\page\templates\default\scripts\ [2] => E:\htdocs\page\application\views\scripts\ 2008/4/14, Matthew Weier O'Phinney <[EMAIL PROTECTED]>: > > -- Serkan Kibritoglu <[EMAIL PROTECTED]> wrote > (on Sunday, 13 April 2008, 10:47 PM +0300): > > 2008/4/13, Matthew Weier O'Phinney <[EMAIL PROTECTED]>: > > -- Serkan Kibritoglu <[EMAIL PROTECTED]> wrote > > (on Sunday, 13 April 2008, 09:47 PM +0300): > > > 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) > > > > > > Hmmm... I haven't noticed that behavior at all. Can you show a short > > reproduce script that reproduces the issue? > > > > Here is the bootstrap: > > > > $view = new Zend_View(); > > $view->addBasePath(realpath('./templates/default/')); > > //$view->addBasePath(realpath('./templates/fashion/')); > > /** > > * Use our $view as renderer > > */ > > > Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->setView > > ($view); > > > > > > > > Here goes the print_r($this->view); in an empty action. > > Zend_View Object > > ( > > [_path:private] => Array > > ( > > [script] => Array > > ( > > [0] => C:\xampp\htdocs\vpage\application\views\scripts\ > > [1] => C:\xampp\htdocs\vpage\templates\default\scripts\ > > ) > > This is correct. 'templates/default/scripts' is the first added path, > and is therefor the last on the stack to be executed. No bug here. > > If you don't trust this, put an index.phtml in each directory with > different contents, and see which one gets rendered (hint, it will be > the one in application/views/scripts/). > > > -- > Matthew Weier O'Phinney > Software Architect | [EMAIL PROTECTED] > Zend - The PHP Company | http://www.zend.com/ >
Re: [fw-general] Changing view path in bootstrap
-- Serkan Kibritoglu <[EMAIL PROTECTED]> wrote (on Sunday, 13 April 2008, 10:47 PM +0300): > 2008/4/13, Matthew Weier O'Phinney <[EMAIL PROTECTED]>: > -- Serkan Kibritoglu <[EMAIL PROTECTED]> wrote > (on Sunday, 13 April 2008, 09:47 PM +0300): > > 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) > > > Hmmm... I haven't noticed that behavior at all. Can you show a short > reproduce script that reproduces the issue? > > Here is the bootstrap: > > $view = new Zend_View(); > $view->addBasePath(realpath('./templates/default/')); > //$view->addBasePath(realpath('./templates/fashion/')); > /** > * Use our $view as renderer > */ > Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->setView > ($view); > > > > Here goes the print_r($this->view); in an empty action. > Zend_View Object > ( > [_path:private] => Array > ( > [script] => Array > ( > [0] => C:\xampp\htdocs\vpage\application\views\scripts\ > [1] => C:\xampp\htdocs\vpage\templates\default\scripts\ > ) This is correct. 'templates/default/scripts' is the first added path, and is therefor the last on the stack to be executed. No bug here. If you don't trust this, put an index.phtml in each directory with different contents, and see which one gets rendered (hint, it will be the one in application/views/scripts/). -- Matthew Weier O'Phinney Software Architect | [EMAIL PROTECTED] Zend - The PHP Company | http://www.zend.com/
Re: [fw-general] Changing view path in bootstrap
2008/4/13, Matthew Weier O'Phinney <[EMAIL PROTECTED]>: > > -- Serkan Kibritoglu <[EMAIL PROTECTED]> wrote > (on Sunday, 13 April 2008, 09:47 PM +0300): > > > Yes Matthew. Thank you for telling me that I've wasted 2 days of my > > life for this. > > > I'll try and make sure this is documented better in the manual. > > > > 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) > > > Hmmm... I haven't noticed that behavior at all. Can you show a short > reproduce script that reproduces the issue? > > Here is the bootstrap: $view = new Zend_View(); $view->addBasePath(realpath('./templates/default/')); //$view->addBasePath(realpath('./templates/fashion/')); /** * Use our $view as renderer */ Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->setView($view); Here goes the print_r($this->view); in an empty action. Zend_View Object ( [_path:private] => Array ( [script] => Array ( [0] => C:\xampp\htdocs\page\application\views\scripts\ [1] => C:\xampp\htdocs\page\templates\default\scripts\ ) [helper] => Array ( [0] => Array ( [prefix] => Zend_View_Helper_ [dir] => C:\xampp\htdocs\vpage\application\views\helpers\ ) [1] => Array ( [prefix] => Zend_View_Helper_ [dir] => C:\xampp\htdocs\vpage\templates\default\helpers\ ) [2] => Array ( [prefix] => Zend_View_Helper_ [dir] => C:\xampp\htdocs\vpage\library\Zend\View\Helper\ ) ) [filter] => Array ( [0] => Array ( [prefix] => Zend_View_Filter_ [dir] => C:\xampp\htdocs\vpage\application\views\filters\ ) [1] => Array ( [prefix] => Zend_View_Filter_ [dir] => C:\xampp\htdocs\vpage\templates\default\filters\ ) [2] => Array ( [prefix] => Zend_View_Filter_ [dir] => C:\xampp\htdocs\vpage\library\Zend\View\Filter\ ) ) ) [_file:private] => [_helper:private] => Array ( ) [_helperLoaded:private] => Array ( ) [_helperLoadedDir:private] => Array ( ) [_filter:private] => Array ( ) [_filterClass:private] => Array ( ) [_filterLoaded:private] => Array ( ) [_filterLoadedDir:private] => Array ( ) [_escape:private] => htmlspecialchars [_encoding:private] => ISO-8859-1 [_strictVars:private] => ) Nothing else in the code. It's just an empty project. > > part of $view dump; > > [script] => Array > > ( > > [0] => .\application\views\scripts\ > > [1] => .\templates\default\scripts\ > > ) > > > The paths are registered as a LIFO stack -- last path in is the first > scanned. Internally, we actually push the beginning of the array so that > we don't have to do an array_reverse later when scanning through the > paths. I know, but index zero is the default path. First is what I add. Which is LILO. > > So it is done with using viewRenderer but remember to remove > > application/view (or whatever) folder to work as we want. > > > You shouldn't need to do this. Can you provide a script showing exactly > what the issue is? If it's truly a bug, I'll fix it in trunk. > > > > 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: > >
Re: [fw-general] Changing view path in bootstrap
2008/4/13, Matthew Weier O'Phinney <[EMAIL PROTECTED]>: > > -- Serkan Kibritoglu <[EMAIL PROTECTED]> wrote > (on Sunday, 13 April 2008, 09:47 PM +0300): > > > Yes Matthew. Thank you for telling me that I've wasted 2 days of my > > life for this. > > > I'll try and make sure this is documented better in the manual. > > > > 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) > > > Hmmm... I haven't noticed that behavior at all. Can you show a short > reproduce script that reproduces the issue? > > Here is the bootstrap: $view = new Zend_View(); $view->addBasePath(realpath('./templates/default/')); //$view->addBasePath(realpath('./templates/fashion/')); /** * Use our $view as renderer */ Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->setView($view); Here goes the print_r($this->view); in an empty action. Zend_View Object ( [_path:private] => Array ( [script] => Array ( [0] => C:\xampp\htdocs\vpage\application\views\scripts\ [1] => C:\xampp\htdocs\vpage\templates\default\scripts\ ) [helper] => Array ( [0] => Array ( [prefix] => Zend_View_Helper_ [dir] => C:\xampp\htdocs\vpage\application\views\helpers\ ) [1] => Array ( [prefix] => Zend_View_Helper_ [dir] => C:\xampp\htdocs\vpage\templates\default\helpers\ ) [2] => Array ( [prefix] => Zend_View_Helper_ [dir] => C:\xampp\htdocs\vpage\library\Zend\View\Helper\ ) ) [filter] => Array ( [0] => Array ( [prefix] => Zend_View_Filter_ [dir] => C:\xampp\htdocs\vpage\application\views\filters\ ) [1] => Array ( [prefix] => Zend_View_Filter_ [dir] => C:\xampp\htdocs\vpage\templates\default\filters\ ) [2] => Array ( [prefix] => Zend_View_Filter_ [dir] => C:\xampp\htdocs\vpage\library\Zend\View\Filter\ ) ) ) [_file:private] => [_helper:private] => Array ( ) [_helperLoaded:private] => Array ( ) [_helperLoadedDir:private] => Array ( ) [_filter:private] => Array ( ) [_filterClass:private] => Array ( ) [_filterLoaded:private] => Array ( ) [_filterLoadedDir:private] => Array ( ) [_escape:private] => htmlspecialchars [_encoding:private] => ISO-8859-1 [_strictVars:private] => ) Nothing else in the code. It's just an empty project. > > part of $view dump; > > [script] => Array > > ( > > [0] => .\application\views\scripts\ > > [1] => .\templates\default\scripts\ > > ) > > > The paths are registered as a LIFO stack -- last path in is the first > scanned. Internally, we actually push the beginning of the array so that > we don't have to do an array_reverse later when scanning through the > paths. I know, but index zero is the default path. First is what I add. > > So it is done with using viewRenderer but remember to remove > > application/view (or whatever) folder to work as we want. > > > You shouldn't need to do this. Can you provide a script showing exactly > what the issue is? If it's truly a bug, I'll fix it in trunk. > > > > 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: > > > >
Re: [fw-general] Changing view path in bootstrap
Thanks for clarifying this, guys. This seems like something that might come up a lot over time. I know that I wrote a pre-1.5 ViewRenderer plugin that performed this logic for me (I used an optional view script setup, too), and it was something of a pain to dig the logic out of ViewRenderer directly. I haven't dug into the 1.5 version yet, but I anticipate easier going with the Layout stuff and the like. On Apr 13, 2008, at 2:48 PM, kirpit wrote: 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/
Re: [fw-general] Changing view path in bootstrap
-- Serkan Kibritoglu <[EMAIL PROTECTED]> wrote (on Sunday, 13 April 2008, 09:47 PM +0300): > Yes Matthew. Thank you for telling me that I've wasted 2 days of my > life for this. I'll try and make sure this is documented better in the manual. > 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) Hmmm... I haven't noticed that behavior at all. Can you show a short reproduce script that reproduces the issue? > part of $view dump; > [script] => Array > ( > [0] => .\application\views\scripts\ > [1] => .\templates\default\scripts\ > ) The paths are registered as a LIFO stack -- last path in is the first scanned. Internally, we actually push the beginning of the array so that we don't have to do an array_reverse later when scanning through the paths. > So it is done with using viewRenderer but remember to remove > application/view (or whatever) folder to work as we want. You shouldn't need to do this. Can you provide a script showing exactly what the issue is? If it's truly a bug, I'll fix it in trunk. > 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/ > > -- Matthew Weier O'Phinney Software Architect | [EMAIL PROTECTED] Zend - The PHP Company | http://www.zend.com/
Re: [fw-general] Changing view path in bootstrap
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/ >
Re: [fw-general] Changing view path in bootstrap
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/ >
Re: [fw-general] Changing view path in bootstrap
-- 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/
[fw-general] Changing view path in bootstrap
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? PS: I've found a solution here exactly what i want but it gives fatal error: http://www.nabble.com/ViewRenderer-action-helper-now-in-core.-td10745347ef16154.html