ras*_*hid 3 categories prestashop
我需要在Prestashop主题的类别页面中列出兄弟类别.目前它确实显示子类别,如果有的话,而不是兄弟类别.
一个快速的答案真的很感激!谢谢.
小智 5
为了开始,我将在/ override/controllers /中创建一个名为CategoryController.php的覆盖文件
并添加这个:
<?php
class CategoryController extends CategoryControllerCore
{
public function displayContent()
{
// Get the global smarty object.
global $smarty;
// Get current category's parent.
$parent_category = new Category($this->category->id_parent, self::$cookie->id_lang);
// Get parent category's subcategories (which is current category's siblings, including it self).
$category_siblings = $parent_category->getSubCategories((int)self::$cookie->id_lang)
/* Assign your siblings array to smarty. */
$smarty->assign(
array(
"category_siblings" => $category_siblings
)
);
/* This we run the normal displayContent, but pass the siblings array to
category.tpl */
parent::displayContent();
}
}
?>
Run Code Online (Sandbox Code Playgroud)
我这是完成它的基本方法,我没有测试过它.您需要找到一种不在兄弟姐妹列表中列出当前类别的方法.
如果代码有效,您现在将在category.tpl中有一个名为category_siblings的数组,您现在需要复制category.tpl中输出子类别的代码,并将子类别arra替换为category_siblings数组.