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

[eluser]shinokada[/eluser]
I applied it to my CMS and it produces the following array.
Code:
Array
(
    [24] => Array
        (
            [id] => 24
            [name] => Main menu
            [shortdesc] => mainmenu
            [status] => active
            [parentid] => 0
            [order] => 0
            [children] => Array
                (
                    [65] => Array
                        (
                            [id] => 65
                            [name] => Main 4
                            [shortdesc] =>
                            [status] => active
                            [parentid] => 24
                            [order] => 0
                            [children] => Array
                                (
                                )

                        )

                    [64] => Array
                        (
                            [id] => 64
                            [name] => Main 3
                            [shortdesc] =>
                            [status] => active
                            [parentid] => 24
                            [order] => 0
                            [children] => Array
                                (
                                )

                        )

                    [62] => Array
                        (
                            [id] => 62
                            [name] => Main 2
                            [shortdesc] =>
                            [status] => active
                            [parentid] => 24
                            [order] => 0
                            [children] => Array
                                (
                                )

                        )

                    [59] => Array
                        (
                            [id] => 59
                            [name] => Main 1
                            [shortdesc] =>
                            [status] => active
                            [parentid] => 24
                            [order] => 0
                            [children] => Array
                                (
                                    [66] => Array
                                        (
                                            [id] => 66
                                            [name] => Main 1-1
                                            [shortdesc] =>
                                            [status] => active
                                            [parentid] => 59
                                            [order] => 0
                                            [children] => Array
                                                (
                                                )

                                        )

                                )

                        )

                )

        )

    [25] => Array
        (
            [id] => 25
            [name] => Galleri 1
            [shortdesc] => galleri1
            [status] => active
            [parentid] => 0
            [order] => 0
            [children] => Array
                (
                )

        )

)

I want to display it in unordered list and table.

I tried it the unordered list first.

The goal is
Code:
<ul>
   <li>Main menu
        <ul>
            <li>Main 4</li>
            <li>Main 3</li>
            ...
            <li>Main 1
                <ul>
                    <li>Main 1-1</li>
                </ul>
            </li>
        </ul>
   </li>
   <li>Galleri 1</li>

</ul>


I attempted the following view.

Code:
if (count($navlist)){
  echo "\n<ul>";
  foreach ($navlist as $key => $list){
      foreach ($list as $topkey => $toplist){
        echo "\n<li class='cat'>\n";
        echo anchor("welcome/cat/",$toplist['name']);
        
        if (isset($toplist['children'])){
        echo "\n<ul>";
            foreach ($toplist['children'] as $subkey => $subname){
                echo "\n<li class='subcat'>\n";
                echo anchor("welcome/cat/",$subname);    
                echo "\n</li>";
            }
        echo "\n</ul>";
        }
    echo "\n</li>\n";
    }
  }
  echo "\n</ul>\n";
}

And this gives 2, M, m etc and errors.
Code:
A PHP Error was encountered

      Severity: Warning

      Message: Invalid argument supplied for foreach()

      Filename: views/admin_menu_home.php

      Line Number: 18

If you can tell me what I am wrong, I will appreciate it.


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