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>




Theme © iAndrew 2016 - Forum software by © MyBB