Hmmm ... I haven't come across the widget-displaying-twice problem, but then
I prevent my 'widgetized' actions being called directly - they can only be
called from the actionstack.  I read that article you linked to but wasn't
100% convinced by his arguments - if you were designing a message board, for
instance, would you really put the login form, search form, and 'most recent
posts' widgets each in a view helper?  

Is the general consensus that actionstack is considered harmful?

Your solution with the <?=action?> does work perfectly - thank you - but is
even more expensive than the action stack.  I can't believe it's not
possible to use placeholders with the actionstack outside the context of a
layout - anyone?

Thanks,
Mark



SirEdward wrote:
> 
> Hi
> 
> Not really gone into this in too much detail but in your layout you could
> try -
> 
> <?= $this->action('actionName', 'controllerName') ?> 
> 
> Also, I use to do a similar thing and put all my widgets in an action. But
> I hated this approach because under the standard routing, if you go to say
> http://mysite.com/controller/action and this is one of your widgets, you
> can end up with the widget displaying twice on the page. So I spent ages
> working on a custom routing to solve this. I also learned very recently
> that by putting your widgets into controller actions you can slow down
> your pages. This article explains it better than I can -
> 
> http://www.rmauger.co.uk/2009/03/why-the-zend-framework-actionstack-is-evil/
> 
> And as a results, I've since moved all my widgets into my own custom view
> helpers, as well as ditching my standard routing, and the results are
> impressive. And because a view helper is allowed to read from a model, it
> means you can keep your models doing all the logic of your application,
> and your helpers can just use this information and render it to your
> liking.
> 
> 
> 
> 
> lightflowmark wrote:
>> 
>> Hi,
>> I'm trying to create a clean, widgetized page using Zend_Layout &
>> ActionStack.  I have a global layout.phtml file with placeholders like 
>> <?= $this->layout()->menu ?>,
>> <?= $this->layout()->content ?>,
>> and am adding the menu action to the ActionStack in a controller plugin
>> from dispatchLoopStartup.  In the menu action I am assigning it to the
>> placeholder like
>> $this->_helper->viewRenderer->setResponseSegment('menu')
>> 
>> All this is working just fine - really easy & clean.
>> 
>> But now I want to have a similar system within my controller actions. 
>> Say I have a primary action I'm trying to view - myPageAction.  My
>> current implementation handles showing the menu and other things, but
>> within myPageAction I want to render content from myWidgetAction and
>> myOtherWidgetAction.  So I push these actions to the actionstack within
>> myPageAction - but how do I render them in placeholders within
>> my-page.phtml?
>> 
>> Code like <?= $this->layout()->menu ?> or <?= $this->layout()->myWidget
>> ?> doesn't render anything within the context of my-page.phtml - does
>> anyone have any insight into how to construct this code?
>> 
>> There's a lot of posts on the forum about this, but I can't find anything
>> that explains it in sufficient detail for me to follow - I'm fairly sure
>> Matthew answers the question in
>> http://www.nabble.com/global-layout----controller-layout-td18401027.html#a18401027
>> but I can't flesh out his reply sufficiently to code it up!
>> 
>> Any insight appreciated.
>> 
>> Yours,
>> Mark
>> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Another-Zend_Layout-question-tp22663886p22676517.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to