2008年8月8日星期五

[fw-mvc] Re: [fw-general] [Zend_View] and global view vars best practice?

-- Laurent Melmoux <laurent@2mx.fr> wrote
(on Friday, 01 August 2008, 06:54 PM +0200):

<snip -- narrative on problems of global view variables now that partials exist>

> So should I do:
> 1) One placeholder + key
>
> $this->placeholder('Mmx_View_Globals')->urlRoot
> $this->placeholder('Mmx_View_Globals')->urlAssets
> $this->placeholder('Mmx_View_Globals')->urlTheme
> $this->placeholder('Mmx_View_Globals')->urlImages
>
> 2) A placeholder for each var
>
> $this->placeholder('urlRoot')
> $this->placeholder('urlAssets')
> $this->placeholder('urlTheme')
> $this->placeholder('urlImages')
>
> 3) A special helper which extends
> Zend_View_Helper_Placeholder_Container_Standalone
>
> $view->globals()->urlRoot
> $view->globals()->urlAssets
> $view->globals()->urlTheme;
> $view->globals()->urlImages

I personally think this option (3) makes the most sense, although I
wouldn't call it 'globals' -- namespace it with something a little more
meaningful or specific to your project. But it makes the implementation
very clean and relatively simple to implement.


> 4) Keep using my current setup
>
> 5) Other suggestions?
>
> What are your recommendations ?
> I'm curious to know how others tackled this problem too.

--
Matthew Weier O'Phinney
Software Architect | matthew@zend.com
Zend Framework | http://framework.zend.com/

没有评论: