Magento 马根托';丢失';输入子类别时的类别

Magento 马根托';丢失';输入子类别时的类别,magento,parent,categories,Magento,Parent,Categories,好吧,我和Magento一起工作了大约1-2个月,对它不太兴奋,但仍在努力学习 我已经为某人安装了一个很好的模板主题,目前我正在调整以使其“正确”工作 但是,我有一个奇怪的问题。。。首先,我的模板没有在顶部导航中显示根类别,只是列出了第一个子类别。这很好 我进入一个子类别,我可以在左栏看到子类别。但是,当我单击其中一个子类别时,左侧块根本不显示任何类别 我可以看出这是默认行为,因为我所在的子类别没有子类别。但是,我想知道,有没有人知道一个好方法,当你在一个孙辈类别中时,显示主基类中的所有类别 E

好吧,我和Magento一起工作了大约1-2个月,对它不太兴奋,但仍在努力学习

我已经为某人安装了一个很好的模板主题,目前我正在调整以使其“正确”工作

但是,我有一个奇怪的问题。。。首先,我的模板没有在顶部导航中显示根类别,只是列出了第一个子类别。这很好

我进入一个子类别,我可以在左栏看到子类别。但是,当我单击其中一个子类别时,左侧块根本不显示任何类别

我可以看出这是默认行为,因为我所在的子类别没有子类别。但是,我想知道,有没有人知道一个好方法,当你在一个孙辈类别中时,显示主基类中的所有类别

EX:
Default Category (Not seen)
  Cat 1 (Shown in top nav)
    Sub Cat 1
    Sub Cat 2
  Cat 2 (Shown in top nav)
    Sub Cat 1
    Sub Cat 2
  Cat 3 (Shown in top nav)
    Sub Cat 1
    Sub Cat 2
比如说,我点击第3类位置的子类2,我可以让magento显示第2级的所有子类吗?在本例中,将显示Cat 3及其所有子类别,几乎就像我只单击了Cat 3一样

我希望我能解释清楚,我和下一个人一样对Magento感到困惑

(这里是foreach循环之前的一部分,用于在我的模板文件中写入类别。是否在这里抛出一个getParent()类的交易,以便它始终加载“top”类别?)



有一个选项,让您在显示内容上有更多选择。它没有您描述的确切行为,但它是朝着正确方向迈出的一步,您可能会发现修改它比完全使用您自己的方法更容易。

左侧类别块的思想是显示当前类别的子类别。听起来你想要一个更静态的菜单,总是显示相同的类别树。这正是顶部导航所做的,因此您可以从那里复制代码,并将其用作左侧块。它甚至有.active CSS类,因此您可以根据活动类别设置样式以折叠/扩展子类别。

确定。我看了提供的两个答案,但是,它们都没有朝我所看到的方向发展

他们各自都很好,然而,我偶然发现了一个更好的线索,我编写了这个窃笑程序:

// Get the current category's path, in array.
// Ex: [0] => '20', [1] => '4'
$_categorypath = $this->getCurrentCategoryPath();

// Use Mage to get a requested Category from the category path from above.
// (The last int in the array is the top-most category, so size-1 gets last int id)
$_parent_category = Mage::getModel('catalog/category')->load($_categorypath[count($_categorypath)-1]);

// Call the children categories from the loaded category
$_categories=$_parent_category->getChildrenCategories();

// Follow the rest of the loop... Success! No "Current/Active" handler yet.. 
$_count = is_array($_categories)?count($_categories):$_categories->count();

if($_count):
// ( Run your foreach code here, complete with html formatting)

我希望这能帮助将来寻找类似功能的其他人。

那么您想要一个包含“姐妹”类别的菜单,而不是子类别的菜单?
// Get the current category's path, in array.
// Ex: [0] => '20', [1] => '4'
$_categorypath = $this->getCurrentCategoryPath();

// Use Mage to get a requested Category from the category path from above.
// (The last int in the array is the top-most category, so size-1 gets last int id)
$_parent_category = Mage::getModel('catalog/category')->load($_categorypath[count($_categorypath)-1]);

// Call the children categories from the loaded category
$_categories=$_parent_category->getChildrenCategories();

// Follow the rest of the loop... Success! No "Current/Active" handler yet.. 
$_count = is_array($_categories)?count($_categories):$_categories->count();

if($_count):
// ( Run your foreach code here, complete with html formatting)