Page 1 of 5 123 ... LastLast
Results 1 to 10 of 43
  1. #1
    Join Date
    Apr 2007
    Posts
    7
    Plugin Contributions
    0

    Default Showing subcategories on the index page

    Hi all

    The normal behaviour of Zen Cart is that you see the subcategories of a category when you click on the category itself (and it opens the relative category page).
    Since I've got only two top-categories on my site, I need that a visitor could see the complete list of subcategories on the sidebox immediately when he opens the site, on the index page.
    I've tried to make it by myself but the sidebox code (tpl_categories, categories, category_tree, etc.) seems to be a little too complicated to understand so I don't know exactly how to change it for my purpose.

    Thanks a lot...

  2. #2
    Join Date
    Apr 2006
    Location
    Ohio
    Posts
    6,162
    Plugin Contributions
    0

    Default Re: Showing subcategories on the index page

    Try this:

    You half to download a module to create the effect you are trying.

    http://www.zen-cart.com/index.php?ma...roducts_id=392

    Mark,
    Mark
    Hare Do

  3. #3
    Join Date
    Apr 2006
    Location
    Ohio
    Posts
    6,162
    Plugin Contributions
    0

    Default Re: Showing subcategories on the index page

    Mark
    Hare Do

  4. #4
    Join Date
    Apr 2007
    Posts
    7
    Plugin Contributions
    0

    Default Re: Showing subcategories on the index page

    THANKS!!

    It works!

    And I've just found that if you don't want to display also products but only subcategories (like me) you have only to comment this line on class category_list.php:

    Code:
    $this->build_products($category_id, $category_link,$level);

  5. #5
    Join Date
    Apr 2006
    Location
    Ohio
    Posts
    6,162
    Plugin Contributions
    0

    Default Re: Showing subcategories on the index page

    Sweet,
    Thanks for the update.
    Nifty idea.

    Mark
    Mark
    Hare Do

  6. #6
    Join Date
    Apr 2007
    Posts
    7
    Plugin Contributions
    0

    Default Re: Showing subcategories on the index page

    There's a problem with the Expanded Category Sidebox...
    it doesn't show the category tree correctly.

    For ex. if the categories are:

    Cat1
    Subcat1
    Subsubcat1
    Subsubcat2
    Subsubcat3
    Subcat2
    Subcat3
    Cat2
    Subcat4
    Subcat5

    the sidebox list them like this:

    Cat1
    Subcat1
    Subsubcat1
    Subsubcat2
    Subsubcat3
    SubCat2
    SubCat3
    Cat2
    Subcat4
    Subcat5


    I think there's some mistakes on the class category_list.php but I can't fix them very easily...


  7. #7
    Join Date
    Apr 2007
    Posts
    4
    Plugin Contributions
    0

    Default Re: Showing subcategories on the index page

    I want to show 10 products of each category on first page .
    Can u help me ?

  8. #8
    Join Date
    Apr 2007
    Posts
    4
    Plugin Contributions
    0

    Default Re: Showing subcategories on the index page

    On my wesite i have 10 categories without subcategories, the products are in categories. I want to show on the first page 10 products of each category, how can i do that ?

  9. #9
    Join Date
    Apr 2007
    Posts
    2
    Plugin Contributions
    0

    Default Re: Showing subcategories on the index page

    hi,

    i tried installing this fix and it doesn't seem to work. does anybody have any suggestions? i know the files have been uploaded to the right place but i'm afraid i may have an override or admin somewhere that's not letting it work.

    the site is here:

    http://www.tracygloverstudio.com/shop

    any help really appreciated - thanks

    rebecca

  10. #10
    Join Date
    Apr 2007
    Posts
    19
    Plugin Contributions
    0

    Default Re: Showing subcategories on the index page

    I followed the same directions as PM Vibe,
    and I am having the same problam,

    my catagories are showing like this

    cat1
    subcat1
    subcat2
    cubcat3

    cat2
    subcat1
    subcat2
    subcat3
    subcat4

    the code I currenrlty have in category_lsit.php

    any help would be appriciated :)
    Code:
    class category_list {    
        var 
            $root_category_id = 0,
            $max_level = 0,
            $data = array(),
            $box_categories_array=array(); 
        
        function category_list() {
            global $languages_id, $db;
            $this->icount=0;
            $this->box_categories_array=array();
            $this->data = array();
            $categories_query = "select c.categories_id, cd.categories_name, c.parent_id
                           from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd
                           where c.categories_id = cd.categories_id
                           and cd.language_id = '" . (int)$_SESSION['languages_id'] . "'
                           order by c.parent_id, c.sort_order, cd.categories_name";
            $categories = $db->Execute($categories_query);
            while (!$categories->EOF) {        
                $this->data[$categories->fields['parent_id']][$categories->fields['categories_id']] = 
                    array('name' => $categories->fields['categories_name'], 'count' => 0);
                $categories->MoveNext();
            }        
        }
      
        function build_branch($parent_id, $level = 0, $parent_link = ''){
            $box_categories_array = & $this->box_category_array;
            $icount = & $this->icount;
            if (!isset($this->data[$parent_id])){ 
                return;
            }
            //next id not used
            $box_categories_array[$icount]['next_id']=false;
            $box_categories_array[$icount]['is_product']=false;
            $box_categories_array[$icount]['level']=$level;
            foreach ($this->data[$parent_id] as $category_id => $category){ 
                if ($parent_id == 0){ 
                    $box_categories_array[$icount]['top']='true';
                }else{
                    $box_categories_array[$icount]['top']='false';
                }
                $category_link = 'cPath='. $parent_link.$category_id;             
                $box_categories_array[$icount]['path'] = $category_link;
                $box_categories_array[$icount]['name'] = $category['name'];
                $box_categories_array[$icount]['count'] = zen_count_products_in_category($category_id) ;
                // this doesn't work :(
                if($category_id == $current_category_id){
                    $box_categories_array[$icount]['current']=true;
                }else{
                    $box_categories_array[$icount]['current']=false;
                }
                if (isset($this->data[$category_id])) { 
                    $box_categories_array[$icount]['has_sub_cat'] = true; 
                } else {
                    $box_categories_array[$icount]['has_sub_cat'] = false; 
                }
                $box_categories_array[$icount]['category_id'] = $category_id;
                $icount++;
    /*            $this->build_products($category_id, $category_link,$level);    */
                if (isset($this->data[$category_id]) && (($this->max_level == '0') || ($this->max_level > $level+1))) {
                    $this->build_branch($category_id, $level+1, $category_link . '_');    
                } 
            }        
            return  $box_categories_array;
        }
        
        function build_products($category_id, $category_link, $level){
            global $languages_id, $db;
            $box_categories_array = & $this->box_category_array;
            $icount = & $this->icount;
            $products_query = "SELECT ". TABLE_PRODUCTS .".products_id, products_name 
                FROM ". TABLE_PRODUCTS." 
                INNER JOIN ". TABLE_PRODUCTS_DESCRIPTION ." 
                    ON ". TABLE_PRODUCTS .".products_id = ". TABLE_PRODUCTS_DESCRIPTION .".products_id 
                WHERE (((". TABLE_PRODUCTS_DESCRIPTION .".language_id)=". (int)$_SESSION['languages_id'] .") 
                    AND ((". TABLE_PRODUCTS .".master_categories_id)=". $category_id ."))
                ORDER BY ". TABLE_PRODUCTS .".products_sort_order, ". TABLE_PRODUCTS_DESCRIPTION .".products_name";
            $products = $db->Execute($products_query);
            if (!$products->EOF){
                while (!$products->EOF){        
                    $box_categories_array[$icount]['count'] = 0 ;
                    $box_categories_array[$icount]['level']=$level;
                    $box_categories_array[$icount]['top']='false';
                    $box_categories_array[$icount]['is_product']=true;
                    $box_categories_array[$icount]['has_sub_cat'] = false;
                    $box_categories_array[$icount]['name']=$products->fields['products_name'];
                    $box_categories_array[$icount]['path']= 'cPath=' . $category_link ."&products_id=".$products->fields['products_id'] ;
                    $box_categories_array[$icount]['products_id']=$products->fields['products_id'] ;
                    //this doesn't work :(
                    if ($products->fields['products_id'] == $products_id){
                        $box_categories_array[$icount]['current']=true;
                    }else{
                        $box_categories_array[$icount]['current']=false;
                    }
                    $products->MoveNext();
                    $icount++;
                }  
            }
            return $result;
        }    
        
        function build_list() {
            return $this->build_branch($this->root_category_id);
        }        
    }

 

 
Page 1 of 5 123 ... LastLast

Similar Threads

  1. Why strange /index/xxx urls showing my index page
    By creamcrackers in forum All Other Contributions/Addons
    Replies: 3
    Last Post: 27 Mar 2012, 03:23 AM
  2. Showing subcategories on home page
    By webfooted in forum Customization from the Admin
    Replies: 0
    Last Post: 6 Aug 2010, 02:53 PM
  3. Showing Add to Cart button, and Categories/SubCategories expanded on Index
    By renode in forum Setting Up Categories, Products, Attributes
    Replies: 7
    Last Post: 2 Oct 2009, 12:29 AM
  4. Replies: 2
    Last Post: 22 Sep 2009, 05:01 PM
  5. Showing subcategories in the category pages
    By thedust2010 in forum Basic Configuration
    Replies: 6
    Last Post: 17 May 2007, 09:49 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR