osCmax v2.5 User Manual
Results 1 to 5 of 5

Box in the Middle: Categories

This is a discussion on Box in the Middle: Categories within the osCommerce 2.2 Modification Help forums, part of the osCommerce 2.2 Forums category; Hi, I would like to offer my wine-shop visitors on the shop-start page all shop categories in the center of ...

      
  1. #1
    New Member
    Join Date
    Sep 2004
    Posts
    7
    Rep Power
    0


    Default Box in the Middle: Categories

    Hi,

    I would like to offer my wine-shop visitors on the shop-start page all shop categories in the center of the page.

    I did not find any documentation or post about how to do it.

    If I just try to include It the way its done in the left colum, I get
    Code:
    Fatal error: Cannot redeclare tep_show_category() (previously declared in /home/www/web11/html/shop/includes/boxes/categories.php:13) in /home/www/web11/html/shop/includes/boxes/categories.php on line 13
    Important: I also want display all cats like its done at yahoo or any other wb directory, not just the top ones,

    Can anybody help?

  2. #2
    New Member
    Join Date
    Sep 2004
    Posts
    7
    Rep Power
    0


    Default

    Made a copy of categories.php and called that one.... Now it works. Dirty trick, i know, if anyone knows a better solution, I would prefer that.

    Still a problem: How do I show all categories? It only gives me the top-categories?
    --
    http://www.gratulatio.de/
    Geburtstage können Sie jetzt ruhig vergessen!

  3. #3
    Active Member
    Join Date
    Jan 2003
    Location
    Surrey, UK
    Posts
    126
    Rep Power
    0


    Default

    You'd need to write a custom categories.php to run through all the categories not just the active one. It wouldn't be hard but you'd need to understand php.


    jon

  4. #4
    New Member
    Join Date
    Sep 2004
    Posts
    7
    Rep Power
    0


    Default

    Yes, I can follow you so far. Since I am a beginner in PHP, I have some problems to analyse the code in categories.php. MAybe you (or someone else) can help a little

    As I read it, it has three parts:

    1. function tep_show_category($counter) to assamble the output HTML
    2.
    Code:
      $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='" . (int)$languages_id ."' order by sort_order, cd.categories_name");
      while ($categories = tep_db_fetch_array($categories_query))  {
        $tree[$categories['categories_id']] = array('name' => $categories['categories_name'],
                                                    'parent' => $categories['parent_id'],
                                                    'level' => 0,
                                                    'path' => $categories['categories_id'],
                                                    'next_id' => false);
    
       if (isset($parent_id)) {
          $tree[$parent_id]['next_id'] = $categories['categories_id'];
        }
    
        $parent_id = $categories['categories_id'];
    
        if (!isset($first_element)) {
          $first_element = $categories['categories_id'];
        }
      }
    To read the top- Categories from teh database

    and 3. everything after
    if (tep_not_null($cPath)) { ....
    to read the subcatagories if cPath is set...

    Now I asume , that only 1 cPath can be handed over.... But what is $cPath_array ? Whats it used for?

    Is there a variable / array that contains all subcategories allready so that I can work with it?
    Or do I have to read them myself from the database?

    I would figure it out by echoing, but echo throws an error message in this part of the code:

    Code:
    Warning: Variable passed to reset() is not an array or object in /home/www/web11/html/shop/includes/boxes/categories.php on line 95


    Any hint will help....

    Thanx carab
    --
    http://www.gratulatio.de/
    Geburtstage können Sie jetzt ruhig vergessen!

  5. #5
    Active Member
    Join Date
    Jan 2003
    Location
    Surrey, UK
    Posts
    126
    Rep Power
    0


    Default

    $cPath_array is constructed in application_top from the cPath _GET variable, you can see it in the title bar whenever you're looking at categories or products. The cPath_array is made by split() ing the $cPath so for example cPath=1_5_34_54 will be made into an array (1,5,34,54).

    You are correct when you say that the cPath_array determines what categories are shown....it runs through until it reaches the end of the array.

    Thinking back, I have made a similar modification to what you want, but it only dealt with one sub-level of categories. It was so I could have a dropdown menu for each top level category. I remember it made my head spin trying to understand the category structure of OSC.

    Sorry I've not been much help but you are on the right tracks.


    jw

Similar Threads

  1. Help with categories
    By krissj in forum osCmax v1.7 Discussion
    Replies: 1
    Last Post: 12-09-2004, 11:41 AM
  2. Want to show categories AND sub categories in index.php!!
    By calle in forum osCommerce 2.2 Modification Help
    Replies: 0
    Last Post: 10-27-2004, 11:51 AM
  3. CATEGORIES BOX does not display categories list
    By glk in forum osCmax v1.7 Discussion
    Replies: 2
    Last Post: 03-05-2004, 10:09 AM
  4. Edit middle of index.php??
    By Anonymous in forum osCmax v1.7 Discussion
    Replies: 3
    Last Post: 09-29-2003, 11:45 AM
  5. categories in MS2 Max
    By gellnsh in forum osCmax v1.7 Discussion
    Replies: 1
    Last Post: 09-25-2003, 01:43 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
  •