|
View:
New views
8 Messages
—
Rating Filter:
Alert me
|
|
|
Sidebar + Common elements -- How to?Hi,
I have 5 views which require a sidebar (out of 30 odd views). I have one layout script. The sidebar content is mostly the same (except for one block which is specific to the view) What is the best way to approach this (in ZF style, of course)? ------------------------------------- Also, I have some HTML that I would like to include is the view based on some CRITERIA. For example...
HTML = If you enjoyed this article. Do consider <a href="/rss" title="RSS 2.0 feed">subscribing to our feed</a> CRITERIA = Search visitor Now, where should I store the HTML? What is the best prtactice for common elements like these?
All help is appreciated. -R
|
|
|
Re: Sidebar + Common elements -- How to?2009/3/9 Raavi Raaj <raaviraaj77@...>:
> Hi, > I have 5 views which require a sidebar (out of 30 odd views). I have one > layout script. > The sidebar content is mostly the same (except for one block which is > specific to the view) > What is the best way to approach this (in ZF style, of course)? There are a few options for this I usually use the Action Stack, though you can look at Action Helper, partials (performance hit), switching layout scripts, View Helpers. Without more detail its hard to say, if its just a static sidebar ie no data I would either use a different layout or a View Helper (View helpers can access your Model too remember). > ------------------------------------- > Also, I have some HTML that I would like to include is the view based on > some CRITERIA. For example... > HTML = If you enjoyed this article. Do consider <a href="/rss" title="RSS > 2.0 feed">subscribing to our feed</a> > CRITERIA = Search visitor > Now, where should I store the HTML? What is the best prtactice for common > elements like these? View Helpers, this is what they are designed to do :) > All help is appreciated. > -R -- ---------------------------------------------------------------------- [MuTe] ---------------------------------------------------------------------- |
|
|
Re: Sidebar + Common elements -- How to?-- Raavi Raaj <raaviraaj77@...> wrote
(on Monday, 09 March 2009, 12:59 PM +0530): > I have 5 views which require a sidebar (out of 30 odd views). I have one layout > script. > The sidebar content is mostly the same (except for one block which is specific > to the view) > > What is the best way to approach this (in ZF style, of course)? > > ------------------------------------- > > Also, I have some HTML that I would like to include is the view based on some > CRITERIA. For example... > HTML = If you enjoyed this article. Do consider <a href="/rss" title="RSS 2.0 > feed">subscribing to our feed</a> > CRITERIA = Search visitor > > Now, where should I store the HTML? What is the best prtactice for common > elements like these? > > All help is appreciated. Typically, I recommend using the placeholder() view helper to aggregate content for sidebars. If the majority of the content is the same for those views requiring the information, I'd create a view helper extending the placeholder() view helper that sets up these items. Then, in your individual action view scripts, you would add your additional items to the placeholder (either prepending or appending to the items already contained), and then render it within that view script. -- Matthew Weier O'Phinney Software Architect | matthew@... Zend Framework | http://framework.zend.com/ |
|
|
Re: Sidebar + Common elements -- How to?is there a difference using a placeholder and just the $this->view->something ?
On Mon, Mar 9, 2009 at 2:22 PM, Matthew Weier O'Phinney <matthew@...> wrote: -- Raavi Raaj <raaviraaj77@...> wrote -- Vincent Gabriel. Lead Developer, Senior Support. Zend Certified Engineer. |
|
|
Re: Sidebar + Common elements -- How to?-- vadim gavrilov <vadimg88@...> wrote
(on Monday, 09 March 2009, 02:31 PM +0200): > is there a difference using a placeholder and just the $this->view->something ? Placeholders allow you to aggregate content in a stack, as well as define text to prepend, append, and separate each item in the stack. Additionally, they persist between view instances. > On Mon, Mar 9, 2009 at 2:22 PM, Matthew Weier O'Phinney <matthew@...> > wrote: > > -- Raavi Raaj <raaviraaj77@...> wrote > (on Monday, 09 March 2009, 12:59 PM +0530): > > I have 5 views which require a sidebar (out of 30 odd views). I have one > layout > > script. > > The sidebar content is mostly the same (except for one block which is > specific > > to the view) > > > > What is the best way to approach this (in ZF style, of course)? > > > > ------------------------------------- > > > > Also, I have some HTML that I would like to include is the view based on > some > > CRITERIA. For example... > > HTML = If you enjoyed this article. Do consider <a href="/rss" title="RSS > 2.0 > > feed">subscribing to our feed</a> > > CRITERIA = Search visitor > > > > Now, where should I store the HTML? What is the best prtactice for common > > elements like these? > > > > All help is appreciated. > > Typically, I recommend using the placeholder() view helper to aggregate > content for sidebars. > > If the majority of the content is the same for those views requiring the > information, I'd create a view helper extending the placeholder() view > helper that sets up these items. Then, in your individual action view > scripts, you would add your additional items to the placeholder (either > prepending or appending to the items already contained), and then render > it within that view script. > > -- > Matthew Weier O'Phinney > Software Architect | matthew@... > Zend Framework | http://framework.zend.com/ > > > > > > -- > Vincent Gabriel. > Lead Developer, Senior Support. > Zend Certified Engineer. > > > > -- Matthew Weier O'Phinney Software Architect | matthew@... Zend Framework | http://framework.zend.com/ |
|
|
Re: Sidebar + Common elements -- How to?Basically same thing as adding it into the registry but being able to use it inside views?
On Mon, Mar 9, 2009 at 3:10 PM, Matthew Weier O'Phinney <matthew@...> wrote: -- vadim gavrilov <vadimg88@...> wrote -- Vincent Gabriel. Lead Developer, Senior Support. Zend Certified Engineer. |
|
|
Re: Sidebar + Common elements -- How to?-- vadim gavrilov <vadimg88@...> wrote
(on Monday, 09 March 2009, 03:11 PM +0200): > Basically same thing as adding it into the registry but being able to use it > inside views? Similar, yes. > On Mon, Mar 9, 2009 at 3:10 PM, Matthew Weier O'Phinney <matthew@...> > wrote: > > -- vadim gavrilov <vadimg88@...> wrote > (on Monday, 09 March 2009, 02:31 PM +0200): > > is there a difference using a placeholder and just the $this->view-> > something ? > > Placeholders allow you to aggregate content in a stack, as well as > define text to prepend, append, and separate each item in the stack. > Additionally, they persist between view instances. > > > > On Mon, Mar 9, 2009 at 2:22 PM, Matthew Weier O'Phinney <matthew@... > > > > wrote: > > > > -- Raavi Raaj <raaviraaj77@...> wrote > > (on Monday, 09 March 2009, 12:59 PM +0530): > > > I have 5 views which require a sidebar (out of 30 odd views). I > have one > > layout > > > script. > > > The sidebar content is mostly the same (except for one block which > is > > specific > > > to the view) > > > > > > What is the best way to approach this (in ZF style, of course)? > > > > > > ------------------------------------- > > > > > > Also, I have some HTML that I would like to include is the view > based on > > some > > > CRITERIA. For example... > > > HTML = If you enjoyed this article. Do consider <a href="/rss" > title="RSS > > 2.0 > > > feed">subscribing to our feed</a> > > > CRITERIA = Search visitor > > > > > > Now, where should I store the HTML? What is the best prtactice for > common > > > elements like these? > > > > > > All help is appreciated. > > > > Typically, I recommend using the placeholder() view helper to > aggregate > > content for sidebars. > > > > If the majority of the content is the same for those views requiring > the > > information, I'd create a view helper extending the placeholder() > view > > helper that sets up these items. Then, in your individual action view > > scripts, you would add your additional items to the placeholder > (either > > prepending or appending to the items already contained), and then > render > > it within that view script. > > > > -- > > Matthew Weier O'Phinney > > Software Architect | matthew@... > > Zend Framework | http://framework.zend.com/ > > > > > > > > > > > > -- > > Vincent Gabriel. > > Lead Developer, Senior Support. > > Zend Certified Engineer. > > > > > > > > > > -- > Matthew Weier O'Phinney > Software Architect | matthew@... > Zend Framework | http://framework.zend.com/ > > > > > > -- > Vincent Gabriel. > Lead Developer, Senior Support. > Zend Certified Engineer. > > > > -- Matthew Weier O'Phinney Software Architect | matthew@... Zend Framework | http://framework.zend.com/ |
|
|
Re: Sidebar + Common elements -- How to?Hi Matthew,
I like this approach. Seems really flexible. A little guidance required here :)... How do I set up the items in the extended view helper e.g. My_View_Helper_Placeholder
Sorry for my above question, I am still learning :) -R On Mon, Mar 9, 2009 at 5:52 PM, Matthew Weier O'Phinney <matthew@...> wrote: -- Raavi Raaj <raaviraaj77@...> wrote |
| Free embeddable forum powered by Nabble | Forum Help |