【发布时间】:2016-11-24 16:02:57
【问题描述】:
我正在 category.tpl 中的 prestashop 上制作自己的面包屑。我有 2 个深度菜单。在子类别页面中,我想在我的面包屑中添加上层类别名称并链接到它。
例如我有菜单 -水果 - -苹果 - -香蕉 -蔬菜 -面包 - -卷 ---面包
当我在苹果页面上时,我想要这样的面包屑:“home
对不起我的英语。希望得到您的回答。
【问题讨论】:
标签: smarty prestashop breadcrumbs
我正在 category.tpl 中的 prestashop 上制作自己的面包屑。我有 2 个深度菜单。在子类别页面中,我想在我的面包屑中添加上层类别名称并链接到它。
例如我有菜单 -水果 - -苹果 - -香蕉 -蔬菜 -面包 - -卷 ---面包
当我在苹果页面上时,我想要这样的面包屑:“home
对不起我的英语。希望得到您的回答。
【问题讨论】:
标签: smarty prestashop breadcrumbs
您可以使用 id_parent 属性获取父类别:
$category->id_parent
您还可以查看当前类别的层级深度以了解何时显示父类别:
{if $category->level_depth > some_int_value}
{* display parent breadcrumb *}
{/if}
祝你好运。
【讨论】:
这并不完全是原始问题的答案,但它可以帮助想要对类别面包屑进行一些更改的人
presta 1.7 - 如果您想将 根类别 添加到面包屑
原路径:首页 > 分类 > 子分类1 > ...
主页 > 根类别 > 类别 > 子类别 1 > ...
controllers/front/listingCategoryController.php
public function getBreadcrumbLinks()
{
$breadcrumb = parent::getBreadcrumbLinks();
// adding root category to breadcrumbs
$rootCategory = Category::getRootCategory();
$breadcrumb['links'][] = array(
'title' => $rootCategory->name,
'url' => $this->context->link->getCategoryLink($rootCategory->id, $rootCategory->link_rewrite),
);
//
foreach ($this->category->getAllParents() as $category) {
if ($category->id_parent != 0 && ! $category->is_root_category) {
$breadcrumb['links'][] = $this->getCategoryPath($category);
}
}
$breadcrumb['links'][] = $this->getCategoryPath($this->category);
return $breadcrumb;
}
【讨论】: