代码之家  ›  专栏  ›  技术社区  ›  nikksan

类别页面产品筛选器

  •  0
  • nikksan  · 技术社区  · 7 年前

    我使用hookDisplayLeftColumn方法的钩子在页面上输出了我的过滤器,但是我有几个问题。 现在我正在挂接leftColumn,但过滤器将显示在任何有它的页面上。我只想在分类页面上显示它。

    public function hookDisplayLeftColumn($params)
        {
    
            $data = array(
                'bar' => 'foo'
            );
    
            $this->context->smarty->assign($data);
            return $this->display(__FILE__, 'categoryfilter.tpl');
        }
    

    这是棘手的部分。如何过滤产品。

    2 回复  |  直到 7 年前
        1
  •  1
  •   sadlyblue    7 年前

    public function hookDisplayLeftColumn($params)
    {
        if (!isset($this->context->controller->php_self) or $this->context->controller->php_self != 'category')
             return false;
    
         $data = array(
             'bar' => 'foo'
         );
    
         $this->context->smarty->assign($data);
         return $this->display(__FILE__, 'categoryfilter.tpl');
    }
    
        2
  •  1
  •   TheDrot    7 年前

    你可以挂到 actionProductListOverride

    钩子在中执行 CategoryController

    可以看到,在params数组中有三个属性。因为它们是通过引用传递的,所以您可以将自己的过滤产品列表和 CategoryController 将有您的过滤数据。

    hookExecuted true 的数据结构 catProducts 应该与 类别控制器 通常生成和 nbProducts 应该有 过滤产品的计数。

    对于你问题的第一部分,sadlyblue给了你答案。