2008年9月10日星期三

Re: [fw-mvc] Controller Menus

Awesome! Thanks for the pointers!

Nikos

On Wed, Sep 10, 2008 at 4:58 AM, monk.e.boy <john.glazebrook@guava.com> wrote:



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.




--
The contents of this message may contain confidential or privileged information and is intended solely for the recipient(s). Use or distribution to and by any other party is not authorized. If you are not the intended recipient, copying, distribution or use of the contents of this information is prohibited.

没有评论: