在菜单中显示子类别而不是根 [英] Show sub category instead of Root in Menu

查看:130
本文介绍了在菜单中显示子类别而不是根的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在域名转移前我的菜单看起来像





我无法理解在域名转移期间发生了什么,现在菜单看起来像



img src =https://i.stack.imgur.com/p8PVh.pngalt =enter image description here>



我的类别结构是

>



我尝试恢复菜单,因为它是在域名转移之前,我已经尝试所有的选项上我的上一个问题在 SO ,但尚未成功...



尝试计算几乎一个星期,但不能..



任何想法?任何指南?如何恢复菜单,因为它是在域转移之前

解决方案

我一个星期以上工作这个问题,最后我得到解决方案..



Infact,这是一个指导方针,从SO问题,位于

我编辑了文件

  app / design / frontend / default / YOU_TEMPLATE / template / catalog / navigation / top.phtml 

我的新代码是

 <?php $ _menu =''?> 
<?php
$ children = Mage :: getModel('catalog / category') - > getCategories(2);

?>
<?php foreach($ children as $ _category):?>
<?php $ _menu。= $ this-> drawItem($ _ category)?>
<?php endforeach?>
<?php if($ _menu):?>
<?php echo $ _menu; >
<?php endif; >

以获取特定根类别的子类别,您可以像

  $ children = Mage :: getModel('catalog / category') - > getCategories(2); 

对于像我这样的麻烦的人来说,这可能会有帮助..



感谢所有


before domain transfer My menu looked like

I cant understand what happened during the domain transfer and now menu looks like

My Category structure is

I am trying to restore the menu as it was before domain transfer, I have tried all the options on my previous question on SO but yet no success...

Trying to figure it out for almost a week, but Can't..

any idea? any guideline? how can I restore the menu as it was before domain transfer??

解决方案

I was working on this problem over a week, and finally I got the solution..

Infact, it was a guideline from SO question, located here

I edited the file

app/design/frontend/default/YOU_TEMPLATE/template/catalog/navigation/top.phtml

and my new code is

<?php $_menu = ''?>
<?php
$children = Mage::getModel('catalog/category')->getCategories(2);

?>
<?php foreach ($children as $_category): ?>
    <?php $_menu .= $this->drawItem($_category) ?>
<?php endforeach ?>
<?php if ($_menu): ?>
        <?php echo $_menu; ?>
<?php endif; ?>

to get the sub catgories of a specific root categories, you can do it like

$children = Mage::getModel('catalog/category')->getCategories(2);

For someone having trouble like me, it might help well..

thanks to all

这篇关于在菜单中显示子类别而不是根的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆