The more basic the menu is I  suggests using an element

if you need to reuse the menu many times in different places I suggest using
a helper

passing a huge array to an element can get unwieldy you can use helpers in
concert with elements;

looking at the example I see that potentially your going to pass a fair
amount to the element; The code for setting this array up before passing to
the element (just IMHO) would be ugly, untidy & harder to maintain in the
view

moving this logic to a helper that in turn calls the element and builds the
array you pass to the element makes sense to me

 - S



On 20 September 2010 04:03, Philip Thompson <[email protected]> wrote:

> Hi all.
>
> I'm wanting to create a simple helper or element which displays a menu.
> I've read around and have seen that others have created helpers which create
> dynamic, database-driven, nested menus. This seems to be too much for my
> needs. I also tend to think that the creation of a menu should be in an
> element.... just cuz it seems "more appropriate" - wish I had more
> justification.
>
> <?php
> $this->element('menu', array(
>    'items' => array(
>        'First' => array('attr'=>'...'),
>        'Second' => array('attr'=>'...'),
>        'Third' => array('attr'=>'...'),
>    ),
> ));
> ?>
>
> Then in the element just loop through the items and display them in an
> unordered list.
>
> So, which would be more appropriate for this functionality - an element or
> a helper? And why?
>
> Thanks!
> ~Philip
>
> http://lonestarlightandsound.com
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others
> with their CakePHP related questions.
>
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]<cake-php%[email protected]>For
>  more options, visit this group at
> http://groups.google.com/group/cake-php?hl=en
>

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to