Welcome Guest, Not a member yet? Register   Sign In
Model problem
#31

[eluser]shinokada[/eluser]
I tried out the view and it kind of works but not quite.

I feel I am repeating my self. If I have the forth level, I have to change it.

Is there any recursive way to simplify it?
Code:
if (count($navlist)){
  echo "\n<ul class='menu'>";
    foreach ($navlist as $key => $menu){
    echo "\n<li class='menuone'>\n";
    echo anchor ("welcome/cat/", $menu['name']);
                
      if (count($menu['children'])){
        echo "\n<ul>";
    foreach ($menu['children'] as $subkey => $submenu){
    echo "\n<li class='menutwo'>\n";
    echo anchor("welcome/cat/",$submenu['name']);
    if (count($submenu['children'])){
    echo "\n<ul>";
      foreach ($submenu['children'] as $subkey => $subsubname){
      // echo "\n<ul>";    
        echo "\n<li class='menuthree'>\n";
        echo anchor("welcome/cat/",$subsubname['name']);    
    echo "\n</li>";
    // echo "\n</ul>";
    }
    echo "\n</ul>";
    }
    echo "\n</li>";
    }
    echo "\n</ul>";
                        }
    echo "\n</li>\n";
                
    }
  echo "\n</ul>\n";
}

Please excuse me for indentation. I just can't get it right here.



I am repeating my self. If I have the forth level, I have to add another code.
There must be recursive way to do it.



Code:
<ul class='menu'>
<li class='menuone'>
<a href="http://127.0.0.1/ci_okadadesign/index.php/welcome/cat">Main menu</a>
<ul>
<li class='menutwo'>
<a href="http://127.0.0.1/ci_okadadesign/index.php/welcome/cat">Main 4</a>
</li>
<li class='menutwo'>
<a href="http://127.0.0.1/ci_okadadesign/index.php/welcome/cat">Main 3</a>
</li>
<li class='menutwo'>
<a href="http://127.0.0.1/ci_okadadesign/index.php/welcome/cat">Main 2</a>
<ul>
<li class='menuthree'>
<a href="http://127.0.0.1/ci_okadadesign/index.php/welcome/cat">Main 2-1</a>
</li>
</ul>
</li>
<li class='menutwo'>
<a href="http://127.0.0.1/ci_okadadesign/index.php/welcome/cat">Main 1</a>
<ul>
<li class='menuthree'>
<a href="http://127.0.0.1/ci_okadadesign/index.php/welcome/cat">Main 1-2</a>
</li>
<li class='menuthree'>
<a href="http://127.0.0.1/ci_okadadesign/index.php/welcome/cat">Main 1-1</a>
</li>
</ul>
</li>
</ul>
</li>
    
<li class='menuone'>
<a href="http://127.0.0.1/ci_okadadesign/index.php/welcome/cat">Galleri 1</a>
</li>
</ul>


Messages In This Thread
Model problem - by El Forum - 12-09-2009, 09:51 AM
Model problem - by El Forum - 12-09-2009, 09:57 AM
Model problem - by El Forum - 12-09-2009, 11:36 AM
Model problem - by El Forum - 12-09-2009, 11:47 AM
Model problem - by El Forum - 12-09-2009, 02:35 PM
Model problem - by El Forum - 12-09-2009, 02:54 PM
Model problem - by El Forum - 12-10-2009, 12:16 AM
Model problem - by El Forum - 12-10-2009, 12:21 AM
Model problem - by El Forum - 12-10-2009, 12:29 AM
Model problem - by El Forum - 12-10-2009, 12:46 AM
Model problem - by El Forum - 12-10-2009, 12:54 AM
Model problem - by El Forum - 12-10-2009, 12:59 AM
Model problem - by El Forum - 12-10-2009, 01:15 AM
Model problem - by El Forum - 12-10-2009, 01:23 AM
Model problem - by El Forum - 12-10-2009, 01:26 AM
Model problem - by El Forum - 12-10-2009, 01:30 AM
Model problem - by El Forum - 12-10-2009, 02:35 AM
Model problem - by El Forum - 12-10-2009, 08:28 AM
Model problem - by El Forum - 12-10-2009, 08:47 AM
Model problem - by El Forum - 12-10-2009, 09:43 AM
Model problem - by El Forum - 12-10-2009, 11:41 AM
Model problem - by El Forum - 12-10-2009, 12:20 PM
Model problem - by El Forum - 12-10-2009, 02:09 PM
Model problem - by El Forum - 12-10-2009, 02:29 PM
Model problem - by El Forum - 12-10-2009, 03:01 PM
Model problem - by El Forum - 12-10-2009, 05:58 PM
Model problem - by El Forum - 12-10-2009, 07:23 PM
Model problem - by El Forum - 12-10-2009, 08:53 PM
Model problem - by El Forum - 12-11-2009, 01:00 AM
Model problem - by El Forum - 12-11-2009, 01:07 AM
Model problem - by El Forum - 12-11-2009, 02:52 AM



Theme © iAndrew 2016 - Forum software by © MyBB