ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

unable to make website SITEMAP(i.e folled by ul li) using php for a table with tree like structure

July 16, 2013 12:28pm

Subscribe [1]
  • #1 / Jul 16, 2013 12:28pm

    james22a

    1 posts

    I have created a CMS website with codeigniter, now I am trying to make website SITEMAP with php coding, but the code which i have made is not complete. i.e It is not showing all the sub menu data properly

    Please look at this image(http://i.stack.imgur.com/xh5WZ.png) According to this image,  I am having many other sub menu under Weight training(sub menu of Fitness Exercises) ,but they are not visible. Why they are not visibile?Please guide/help me to solve this issue

    My php code
    
           foreach ($query_sitemap as $artrow) {
                $datefromsql = $artrow->created_date;
                  $time = strtotime($datefromsql);  ?> 
                                
                            
                                <ul>
                                    <?php echo '<b>'.$artrow->menu_name.'</b>'; ?>
                                     
                                        
                                        <?php $submenucon=$this->menumodel->fetch_menu_byPid($artrow->id);//i.e select*from menu where parent_id=$mid
                                         if (empty($submenucon)) { ?>
                                          ---
                                         <?php
                                            } else {
                                                 foreach ($submenucon as $subtrow) {
                                                     ?>
                                                      <?php echo '<li >'.$subtrow->menu_name.'</li><br>'; ?>
                                              <?php
                                                 }
                                            }
                                         ?>    
                                </ul> 
                                 
                                <?php
                                $i++;
                            }
                        }    ?>

     

    **My db struture is**   
    
           Table: menu
        ---------------
         id   PK(primary key)
         menu_name     ..... 
         content      longtext
         parent_id    int(key to id)
    
    This is an example of the data stored in the table:
    
        Example
        ----------------
        id | menu_name | content | parent_id
        ----------------------------------------
        1  | main 1    | this is main menu 1 | 0                           <-- First level menu
        2  | main 2    | this is main menu 2 | 0                           <-- First level menu  
        3  | submenu 1 | this is main menu 1's first submenu's item 1 | 1  <-- Second level menu
        4  | submenu 1 | this is main menu 1's first submenu's item 2 | 1  <-- Second level menu
        5  | submenu 2 | this is main menu 2's first submenu's item 1 | 2  <-- Second level menu

     

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases