2009年2月20日星期五

Re: [fw-mvc] Widgetized content with Zend_Layout

Murphy-8 wrote:
>
> Hi,
>
> I have a hard time trying to find a solution for this scenario:
>
> I have a controller called "auth" for displaying a small "account
> information box" if a user is logged in,
> or a "login-box" or "lost password", when no user is authenticated.
> This is supposed to be my widget for all things related to
> authentication and user information.
> I don't want to couple it with the rest of the application, because i
> want to be able to request
> this widgets output e.g. "/auth/account" via AJAX later on.
>
> But for the usual http request I just want to integrate it into the
> layout rendered by Zend_Layout.
> I tried it with a Front Controller Plugin and called in "postDispatch":
>
> $this->getResponse()->insert('auth', $view->action('index','auth'));
>
>
I suggest you to use ActionStack in this case to put "authAction" to the
stack (you can do this in the dispatchLoopStartup() method of your plugin).
So in it's turn IndexController::authAction will put all it's output to the
named segment as shown:

[IndexController.php]
...
public function authAction()
{
[some logic]
$this->_helper->ViewRenderer->setResponseSegment('auth');
}

[layout.phtml]
<div id="sidebar">
<?= $this->layout()->auth ?>
</div>

And I guess you still can use _forward() freely since responseSegment was
redefined in authAction.


-----
--
Alexander Anokhim
AVTOVAZ JSC
--
View this message in context: http://www.nabble.com/Widgetized-content-with-Zend_Layout-tp22112654p22117715.html
Sent from the Zend MVC mailing list archive at Nabble.com.

没有评论: