首页>Magento>source

我想对 catalog/category的布局句柄有一个具体而准确的解释   页。

据我所知,我知道有三种不同的布局句柄: catalog_category_viewcatalog_category_defaultcatalog_category_layered

如果我们看一下 Mage_Catalog_Model_Category::getLayoutUpdateHandle()   我们会看到:

public function getLayoutUpdateHandle()
{
    $layout = 'catalog_category_';
    if ($this->getIsAnchor()) {
        $layout .= 'layered';
    }
    else {
        $layout .= 'default';
    }
    return $layout;
}

所以 catalog_category_layered   当 is_anchor加载   设置为 yes ,否则 catalog_category_default   是谁将被装载。

那么 catalog_category_view呢   ?

在我的情况下,在我的 catalog/product   页面我有 catalog_category_view   作为 layered navigation的布局句柄   如果我把一些类别设置为 is_anchor   是的,我仍然总是有相同的布局 catalog_category_view   ?

最新回答
  • 2019-12-5
    1 #

    你应该有类别页面的多个句柄(肯定超过5个).如果您想知道哪个句柄用于特定页面,您可以在页面模板中添加以下代码:

    <?php
    Zend_Debug::dump($this->getLayout()->getUpdate()->getHandles());
    ?>
    

    (例如在 app/design/frontend/<your-package>/<your-theme>/template/catalog/category/view.phtml   模板)

    catalog_category_view   应始终存在于类别页面中,因为对于控制器的每个操作,Magento将创建一个名为 routerName_controllerName_actionName的句柄   (当你在类别页面时调用的动作是 viewAction()   categoryController.php   Mage_Catalog模块   有路由器名称 catalog )。

    如果使用 is_anchor设置了类别   是的,它应该添加另一个句柄 catalog_category_layered   正如你提到的那样。

    希望它会有所帮助。

  • 2019-12-5
    2 #

      catalog_category_view   适用于所有类别页面

      catalog_category_default   仅适用于将锚设置为 no的页面 catalog_category_layered   仅适用于将锚设置为 yes的页面

  • 避免在addError()中重复出现错误消息
  • database:为什么实体值基于属性类型存储在不同的表中?