2008年9月10日星期三

Re: [fw-mvc] Controller Menus

Nikos Dimopoulos wrote:
>
> My understanding of the actionStack is that is just performs an action
> (duh)
> no matter what. You set a priority for it (avoid 99 because it is
> reserved)
> and that does the trick. You then set in the actionStack the
> controller/action you need to 'run' and that is it.
> So in the above by Pawel, the actionStack will run the menu action from
> the
> index controller. You then set the code to generate the menu in that
> action
> and the menu appears.
>

Sorry, although that was very interesting and answered a lot of questions. I
did wonder why use another controller when you could just use the view to
call the correct menu. But this would require logic in the view?


Nikos Dimopoulos wrote:
>
>
> Personally I have found this to work like a charm if you want to have a
> static menu and just display it. Since I didn't know how to have variables
> passed based on the action clicked so that I can do fancy stuff with the
>

You can pass variables to the controller like this:
$this->_helper->actionStack('application', 'menu', 'default',
array('var1'=>'moo', 'var2'=>'boo'));

Then in ApplicationController::menuAction you can:

$x = $this->_getParam( 'var1' );
$y = $this->_getParam( 'var2' );

I am passing in my action:

$this->_helper->actionStack('application', 'menu', 'default',
array( 'show_menu'=>$this->getRequest()->action ));

as a variable, then using this to look up the menu item to highlight.

Seems to work OK :-)


Nikos Dimopoulos wrote:
>
> I hope this helps.
>
> Nikos
>

It did, thanks :-) I did a lot of experimenting to get this far ;-)

I hope google indexes all this so other people don't get as stuck as I was
;-)

monk.e.boy

--
View this message in context: http://www.nabble.com/Controller-Menus-tp19390796p19409354.html
Sent from the Zend MVC mailing list archive at Nabble.com.

没有评论: