Make menus and submenus the same model (no associations, just use
parent_id) and then always use findAllThreaded() I have found that to
be the best solution in similar situations as then there is only one
data structure (in the same format each time) to traverse. I usually
build the menu with recursion.

If you want breadcrumbs as well then you might want to use the
TreeBehavior as it has a getPath () wich will make this easy.

Geoff
--
http://lemoncake.wordpress.com

On Aug 3, 5:05 am, phirschybar <[EMAIL PROTECTED]> wrote:
> there is a model behavior called 'tree'. Have never used it but might
> be worth taking a look.
>
> On Aug 2, 12:48 pm, omeck <[EMAIL PROTECTED]> wrote:
>
> > Hi,
> > I have done menu with submenus. I used relations
> > Menu hasMany Link
> > Link belongsTo Menu
>
> > I get data by $this->set('menusLeft', $this->Menu->findAll('page_pos =
> > 1', '', 'Menu.pos ASC'));
> > and display:
> > <?php
> > foreach ($menusRight as $menu) {
> >         echo '<div class="menuSep">' . $menu['Menu']['name'] . '</div>';
>
> >         foreach ($menu['Link'] as $link) {
> >                 if ($link['new_window'] == 1)
> >                         echo '<div class="menuLink">' . 
> > $html->link($link['name'], '/links/view/' . $link['url'], array('onclick' =>
>
> > 'return!window.open(this.href)')).'</div>';
> >                 else
> >                         echo '<div class="menuLink">' . 
> > $html->link($link['name'], '/links/
> > view/' . $link['url']).'</div>';
> >         }
> >         echo $menu['Menu']['code_block'];}
>
> > ?>
>
> > So I get:
>
> > Menu1
> > * submenu1
> > * submenu2
> > * sumbenu3
> > Menu2
> > * sumbenu5
> > * submenu6
>
> > etc.
>
> > Today I decided that I need sumenus to submenus - submenus should have
> > children. I added filed 'parent_id'  to links table.
>
> > My problem is how to prapare data?
> > $this->Menu->findAll() and $this->Menu->Link->findAllThreaded() give
> > me different results which a cannot( or i am not able to ;-)) use to
> > build structure:
>
> > Menu1
> > *submenu1
> > * submenu2
> >    * sumbenu3
> >    *submenu4
> > * submenu5


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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