Sanjoy Roy

[MCM, MCP, SCJP] – Senior PHP Programmer

show all categories expanded


$aa = 0;
    $info_box_contents = array();
   // $info_box_contents[] = array('text'  => '' . BOX_HEADING_CATEGORIES4 . '');
  //  new infoBoxHeading($info_box_contents);
  //  $categories_string4 = '';
    if(!$_SESSION['sppc_customer_group_id']) {
      $customer_group_id = 'G';
    } else {
     $customer_group_id = $sppc_customer_group_id;
    }
    $categories_query = tep_db_query("SELECT c.categories_id, cd.categories_name, c.parent_id 
                                        from " . TABLE_CATEGORIES . " c,
                                             " . TABLE_CATEGORIES_DESCRIPTION . " cd 
                                      WHERE c.parent_id = '0' 
                                        and c.categories_id = cd.categories_id 
                                        and cd.language_id='" . $languages_id ."' 
                                      ORDER BY sort_order, cd.categories_name");					  
 
    while ($categories = tep_db_fetch_array($categories_query))  {
		$foo[$categories['categories_id']] = array('name' => $categories['categories_name'],
                                                 'parent' => $categories['parent_id'],
                                                 'level' => 0,
                                                 'path' => $categories['categories_id'],
                                                 'next_id' => false
                                                );
					 if (isset($prev_id)) {
        $foo[$prev_id]['next_id'] = $categories['categories_id'];
      }
      $prev_id = $categories['categories_id'];
      if (!isset($first_element)) {
        $first_element = $categories['categories_id'];      }
	  
	  $categories_query2 = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . $categories['categories_id'] . "' and c.categories_id = cd.categories_id and cd.language_id='" . $languages_id ."' order by sort_order, cd.categories_name");	 
        $category_check = tep_db_num_rows($categories_query2);
        if ($category_check > 0) {
          $new_path = $categories['categories_id'];
          while ($row = tep_db_fetch_array($categories_query2)) {
            $foo[$row['categories_id']] = array('name' => $row['categories_name'],
                                                'parent' => $row['parent_id'],
                                                'level' => $key+1,
                                                'path' => $new_path . '_' . $row['categories_id'],
                                                'next_id' => false
                                               );
            if (isset($prev_id)) {
              $foo[$prev_id]['next_id'] = $row['categories_id'];
            }
            $prev_id = $row['categories_id'];
		  }
		}   
	  
    }  	
	
    tep_show_category4($first_element);

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: