【问题标题】:Showing all osCommerce categories and subcategories on left hides products list from home page在左侧显示所有 osCommerce 类别和子类别会隐藏主页中的产品列表
【发布时间】:2011-03-23 14:27:23
【问题描述】:

我更改了一些 osCommerce 代码以在左侧边栏中显示所有类别和子类别,并且它可以成功运行。

不幸的是,它在主页上隐藏了产品。在 osCommerce 网站的默认主页上,我们会获取当月的产品并显示所有产品。

如果我跳过下面所做更改的第 2 步,它会显示产品,但左侧导航不会显示所有类别和子类别。

步骤:

  1. index.php - 在第 37 行左右更改:

    if ($category_depth == 'nested') {
    

    收件人:

    if ($category_depth == 'nested' && isset($HTTP_GET_VARS['cPath'])) {
    
  2. includes/application_top.php - 更改第 437 行:

    $cPath = '';
    

    收件人:

     $cPath = '22';
    
  3. includes/modules/boxes/bm_categories.php - 在第 99 行附近找到:

     $parent_id = $categories['categories_id'];
    

    添加:

     $dbs[] = $categories['categories_id'];
    
  4. includes/modules/boxes/bm_categories.php - 在第 109 行左右更改:

     while (list($key, $value) = each($cPath_array)) {
    

    收件人:

     while (list($key, $value) = each($dbs)) {
    

为什么会出现问题?

【问题讨论】:

  • 等待任何 oscommerce 大师的回复..

标签: php oscommerce


【解决方案1】:
function  single_genealogy($category,  $level  =  0){
              global $tree, $categories_string;
        // the sons of the current node = the IDs that are matched with this parentid
            $q  =  "select c.categories_id, cd.categories_name, c.parent_id from categories c , categories_description cd
             where c.parent_id ='".$category."' and c.categories_id = cd.categories_id order by sort_order , cd.categories_name";
             $r  =  mysql_query($q);  //or  die/mail/echo  mysql_error()
               $level++;
             $categories_string .= "<ul>";
               while($d  =  mysql_fetch_row($r)){
                    $cPath_new = 'cPath='.$d[0];
                 $categories_string .=  '<li><a href='.tep_href_link(FILENAME_DEFAULT, $cPath_new).'>'.$d[1].'</a>';
                 //displaying  current  node  :  $d[1]
                  //recursive  call  :
                 $this->single_genealogy($d[0],  $level);
echo "</li>";
                }
            $categories_string .=  "</ul>";    
        }


You need to put this function in bm_categories and call this function in getData()
and you simply find your all categories tree of product.
And now for applying navigation effect using css and jquery you can use www.htmldrive.net

【讨论】:

  • Akshay - 这太棒了!您是否知道在用户浏览树时保持面包屑路径完整?用户深入导航后,他们会收到“顶部 > 类别”,其中应该是面包屑中的“顶部 > 父 > 子 > 孙 > 曾孙”。
【解决方案2】:

将第二步改为如下:

$cPath = '0';

您现在拥有的 $cPath = '22'; 指的是无效的类别 ID。

如果您将默认类别路径 ID 设置为顶部,即零 (0),这将纠正问题并默认显示该月的新产品。

如果您将该值更改为子类别 ID,则该类别中的产品将默认显示在主页上。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多