【发布时间】:2012-03-07 09:57:16
【问题描述】:
我正在寻找一种方法来对导航中类别的前端显示进行排序。
这是我的导航代码:
<div id="menu-accordion" class="accordion">
<?php
foreach ($this->getStoreCategories() as $_category): ?>
<?php $open = $this->isCategoryActive($_category) && $_category->hasChildren(); ?>
<h3 class="accordion-toggle"><a href="#"><?php print $_category->getName();?></a></h3>
<div class="accordion-content">
<ul>
<?php foreach ($_category->getChildren() as $child): ?>
<li>
<span class="ui-icon ui-icon-triangle-1-e vMenuIconFloat"></span>
<a href="<?php print $this->getCategoryUrl($child); ?>"><?php print $child->getName();?></a>
</li>
<?php endforeach; ?>
</ul>
</div>
<?php endforeach ?>
</div>
我尝试使用asort() 对$this->getStoreCategories() 进行排序,但它解决了错误500,所以我猜它不是一个数组,而是一个对象(这对于magento 的面向对象编程来说似乎很明显)。我试图找到对象的解决方案,但失败了,现在我有点卡住了。
感谢您的帮助。
【问题讨论】:
标签: php arrays sorting magento object