menu sub menu

bharanikumariyerphp's picture
public
bharanikumariyerphp - Wed, 2008-06-18 12:59

Dear

am creating custom menu and submenu(like parent and child)

This is the code am using.. u see in my table am having three content type, but three content type

Not displaying , last two only displaying..

I want to know the reason..

Where i Made the mistake....

/**
* Implementation of hook_menu($may_cache).
*/
function cShow_menu($may_cache) {
global $ctype;
//globally declared


$sql = 'select type from node_type ';
echo "This is query".$sql;

//This is while loop display the content types
$res = db_query($sql);
while ($row = db_fetch_array($res)) {
//end of of

$ctype=$row['type'];
echo "what is  type".$ctype;

$content = array();
$content[] = array(
'title' => t('Contents'),
'path' => 'cShow',
'callback' => 'cShow_article',
'access' => user_access('authenticated user')
);


$path =  'cShow/'.$row['type'] ;
$content[] = array(
'title' => t($row['type']),
'path' =>"$path",
'callback' => "cShow_common",
'access' => user_access('authenticated user')
);return $content;
}
//end of while loop

}

function cShow_article(){

$pageQuery = "SELECT n.created, n.title, n.type, n.created, n.nid, n.uid, n.changed
  FROM node n
  WHERE n.status = 1 order by n.type desc";

  $countQuery=" SELECT count( nid )FROM node ";
//echo $pageQuery,"<br>",$countQuery;

   $result=db_query($pageQuery);
 
   $num=db_num_rows($result);
  // echo "<br>".$num;
 
 
   if($num>0){
  // echo "<br>If greater";


$output .= "<div class=\"item-list\"><table width=600 cellspacing=0 cellpadding=0 border=0><tr><td width=10><input type=checkbox name=checkbox id=checkbox /></td><td width=190><b>Title</b></td><td width=100><b>Type</b></td><td width=60><b>Author</b></td><td width=170><b>Published Date</b></td><td width=50><b>Operations</b></td></tr><ul>";
  $color="1";

   $result1 = pager_query($pageQuery,10,"0",$countQuery);
//   echo "<br>"."This is Result 1".$result1;
 
 
   while ($node = db_fetch_object($result1)) {
   $user_id=$node->uid;
   $authername="SELECT name FROM users WHERE uid =$user_id";
   $affect=db_query($authername);
//  echo "<br>This is".$affect;
 
 
   while($row = db_fetch_object($affect))
  {
  $author=$row->name;
// echo "<br>This is the author &nbsp;".$author;
  }
  $created=$node->created;
  $created_date=date("D, j M, Y \a\t G:i", $created);
// echo "This is create date".$created_date;


  if($color==1){

   $output .= "<tr bgcolor=#edf5fa><td width=10><input type=checkbox name=checkbox id=checkbox /></td><td width=190>" . l($node->title, "node/".$node->nid) ."</td><td width=100>". l($node->type, "node/".$node->nid) ."</td><td width=60>". l($author, "node/".$node->nid) ."</td><td width=200>". l($created_date, "node/".$node->nid) ."</td><td width=50>" . l("Edit", "node/".$node->nid."/edit")."</td></tr>";
//"&nbsp;&nbsp;&nbsp;" .  l("Delete", "node/".$node->nid."/delete")  .

$color="2";
}

else
{
    $output .= "<tr bgcolor=#ffffff><td width=10><input type=checkbox name=checkbox id=checkbox /></td><td width=190>" . l($node->title, "node/".$node->nid) ."</td><td width=100>". l($node->type, "node/".$node->nid) ."</td><td width=60>". l($author, "node/".$node->nid) ."</td><td width=200>". l($created_date, "node/".$node->nid) ."</td><td width=50>" . l("Edit", "node/".$node->nid."/edit")."</td></tr>";
//"&nbsp;&nbsp;&nbsp;" .  l("Delete", "node/".$node->nid."/delete")  .

$color="1";


  }
}
$output .= "</table></ul></div>";
//return $output;
return $output .= theme('pager', NULL, variable_get('default_nodes_main', 10));
}
else
{
    return t("<br><b>No record found</b>");
}
}

    function cShow_common(){
 
       echo "Am entering";
     global $ctype;
  $pageQuery = "SELECT n.created, n.title, n.type, n.created, n.nid, n.uid, n.changed
    FROM node n
    WHERE n.status = 1 and n.type='$ctype' order by n.type desc";
   echo $pageQuery;
   echo "hello".$ctype."<br/>";
    

     $cShow_type=$row->type;
      $countQuery="SELECT count( nid )FROM node where type='$ctype'";
   
   echo "test".$pageQuery,"<br>",$countQuery;

       $result=db_query($pageQuery);
     
       $num=db_num_rows($result);
    // echo "<br>".$num;
   
      
       if($num>0){
    //    echo "<br>If greater";
    
      
       $output .= "<div class=\"item-list\"><table width=600 cellspacing=0 cellpadding=0 border=0><tr><td width=10><input type=checkbox name=checkbox id=checkbox /></td><td width=190><b>Title</b></td><td width=100><b>Type</b></td><td width=60><b>Author</b></td><td width=170><b>Published Date</b></td><td width=50><b>Operations</b></td></tr><ul>";
         $color="1";
         
        $result1 = pager_query($pageQuery,10,"0",$countQuery);
        //   echo "<br>"."This is Result 1".$result1;
          
          
           while ($node = db_fetch_object($result1)) {
                $user_id=$node->uid;
                $authername="SELECT name FROM users WHERE uid =$user_id";
                $affect=db_query($authername);
               //  echo "<br>This is".$affect;
                 
                  
                   while($row = db_fetch_object($affect))
                        {
                              $author=$row->name;
                            // echo "<br>This is the author &nbsp;".$author;
                        }
                  $created=$node->created;
                $created_date=date("D, j M, Y \a\t G:i", $created);
                // echo "This is create date".$created_date;
                 
              
               if($color==1){
  
                                  $output .= "<tr bgcolor=#edf5fa><td width=10><input type=checkbox name=checkbox id=checkbox /></td><td width=190>" . l($node->title, "node/".$node->nid) ."</td><td width=100>". l($node->type, "node/".$node->nid) ."</td><td width=60>". l($author, "node/".$node->nid) ."</td><td width=200>". l($created_date, "node/".$node->nid) ."</td><td width=50>" . l("Edit", "node/".$node->nid."/edit")."</td></tr>";
//"&nbsp;&nbsp;&nbsp;" .  l("Delete", "node/".$node->nid."/delete")  .
 
   $color="2";
  }
 
               else
               {
                                  $output .= "<tr bgcolor=#ffffff><td width=10><input type=checkbox name=checkbox id=checkbox /></td><td width=190>" . l($node->title, "node/".$node->nid) ."</td><td width=100>". l($node->type, "node/".$node->nid) ."</td><td width=60>". l($author, "node/".$node->nid) ."</td><td width=200>". l($created_date, "node/".$node->nid) ."</td><td width=50>" . l("Edit", "node/".$node->nid."/edit")."</td></tr>";
    //"&nbsp;&nbsp;&nbsp;" .  l("Delete", "node/".$node->nid."/delete")  .
 
   $color="1";
 
  
     }
    }
  $output .= "</table></ul></div>";
  //return $output;       
  $output .= theme('pager', NULL, variable_get('default_nodes_main', 10));
  
   return $output;
    }
   else
  {
      return t("<br><b>No record found</b>");
    } 
}