2009年2月20日星期五

Re: [fw-mvc] Widgetized content with Zend_Layout

Hi Alexander,

I tried your solution (had checked out actionStack before) and it
kinda works, the only open problem:

$this->_helper->viewRenderer->setResponseSegment('auth') has to be
called in every action of my authController to be rendered in the
layout()->nav section of my layout template.
This also means that the action output can never be rendered in
content again, not even when I want to display it there by directly
calling the controller/action combination.

And calling the action directly results in it being displayed twice in
layout()->nav and with empty layout()->content.
Having it displayed only once could be a solution I could go with,
since I will have to figure out a session-based solution for that
anyway:
Imagine you enter the site, got to /news/list and then decide to login
to the site via the auth widget thats displayed in the sidebar.
You click login and the widget changes to the login box (either after
a reload, or fetched through ajax) but the layout()->content stays at /
news/list.

bye,
Murphy

On Feb 20, 2009, at 10:47 AM, Alexander Anokhin wrote:

>
>
>
> 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.
>

没有评论: