【发布时间】:2013-11-29 17:58:24
【问题描述】:
我环顾四周,发现了很多关于提取父 ID 和子猫列表的信息,但这略有不同,我似乎无法找到答案,我还不是 PHP 专家(还) 所以对我放轻松。我尝试了各种方法,但最终都出现了错误。
我创建了一个 phtml 模板,用于在主导航下方的内联链接块中显示父类别的子类别。我用管理员的静态块调用这个模板,它工作正常,但是当我导航到子类别页面时,链接块消失了,显然是因为这段代码调用了父级的子猫,但当你实际上在子猫。这是我目前使用的代码:
<?php if (!Mage::registry('current_category')) return ?>
<?php $_categories = $this->getCurrentChildCategories() ?>
<?php $_count = is_array($_categories)?count($_categories):$_categories->count(); ?>
<?php if($_count): ?>
<div class="category-products <?php echo Mage::getModel('catalog/layer')->getCurrentCategory()->getName(); ?>">
<dl id="narrow-by-list2">
<dt></dt>
<dd>
<ol class="subcat_list">
<?php foreach ($_categories as $_category): ?>
<?php if($_category->getIsActive()): ?>
<li>
<a href="<?php echo $this->getCategoryUrl($_category) ?>"<?php if ($this->isCategoryActive($_category)): ?> class="current"<?php endif; ?>><?php echo $this->htmlEscape($_category->getName()) ?></a>
</li>
<?php endif; ?>
<?php endforeach ?>
</ol>
</dd>
</dl>
<script type="text/javascript">decorateDataList('narrow-by-list2')</script>
</div>
<?php endif; ?>
关于如何修改它以便在我实际查看子猫时列表保留在那里的任何想法? 非常感谢
【问题讨论】:
标签: php magento categories