u can make recursive function in helper.
Maybe U need only recursive call implement to your code:
if (isset($item['children']) && is_array($item['children']) &&
count($item['children']))
{
        $out .= $this->menu($id_selector, $htmlAttributes=null, $_sublevel+1,
$item['children']);
}

menu array should be "findAllThreaded" format

/**
 * Generate menu with ul li markup
 * @access public
 * @since 9/21/2006 18:37:17
 * @author Majna, Tomo and Agnezija
 * @param string $id_selector a key used for selection elements from
specific menu position. eg. main_menu, footer
 * @param array $htmlAttributes html atributes for menu
 * @param integer $_sublevel private sublevel counter,
 * @param array $recursive_data private menu data send to recursive
call,
 * @return string
**/
        function menu($id_selector = null, $htmlAttributes = null,
$_sublevel=0, $recursive_data=null)
        {
                if (empty($recursive_data))
                {
                        if ( 
isset($this->view->viewVars['menusArray'][$id_selector]) && !
empty($this->view->viewVars['menusArray'][$id_selector]) )
                        {
                                $data = 
$this->view->viewVars['menusArray'][$id_selector];
                        }
                }
                else
                {
                        $data = $recursive_data;
                }

                if (empty($data))
                {
                        return '';
                }
                else
                {
                        $extraTabIndent = '';
                        $out="\n\r\t\t\t\t\t";

                        for ($i=0; $i < $_sublevel; $i++)
                        {
                                $extraTabIndent.= "\t\t";
                        }

                        $i=0;
                        $out.= $extraTabIndent.'<ul'.$this->html-
>_parseAttributes($htmlAttributes) . '>';

                                foreach ($data as $item)
                                {
                                        if ($item['MenuType']['id_selector'] == 
$id_selector)
                                        {
                                                $active = ($this->here == 
$item['Menu']['url'])? '
class="active"':'';
                                                $out .= 
"\n\r\t\t\t\t\t\t".$extraTabIndent.'<li'.$active.'>';
                                                $out .= 
$this->html->link($item['Menu']['name'],$item['Menu']
['url'], null, false, false);

                                                        if 
(isset($item['children']) && is_array($item['children']) &&
count($item['children']))
                                                        {
                                                                $out .= 
$this->menu($id_selector, $htmlAttributes=null,
$_sublevel+1, $item['children']);
                                                        }
                                                $out .= '</li>';
                                        }
                                }
                        $out .= "\n\r\t\t\t\t\t".$extraTabIndent.'</ul><!-- '.
$id_selector    .' -->';

                        if ($_sublevel > 0)
                        {
                                $out.="\n\r\t\t\t\t".$extraTabIndent;
                        }
                        else
                        {
                                $out.="\n\r\n\r";
                        }

                        return $this->output($out);
                }
        }

On May 4, 5:38 pm, "Tane Piper" <[EMAIL PROTECTED]>
wrote:
> Hi folks,
>
> I've pasted some code here:  http://bin.cakephp.org/view/1509962324
>
> What I am looking to do is instead of hard-coding the 3 levels of menu
> that I produce from my findAllThreaded method in the controller, I
> would like to be able to produce "infinite" levels of menus from the
> data returned in as little code as possible, and possibly move it into
> a helper as I would also like to do the same with select lists (for
> when setting menus, I 'd like to easily be able to select the parent.
>
> Any help on this would be much appreciated.
>
> Tane


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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