我创建了一个cms页面。在内容字段中输入以下行:
{{block type="catalog/navigation" template="catalog/category/list.phtml"}}
然后创建代码为的list.phtm
<?php
$helper = Mage::helper('catalog/category');
$collection = $helper->getStoreCategories('name', true, false);
foreach ($array as $cat) {
echo '<a href="'.$this->getCategoryUrl($cat).'">'.$cat->getName().'</a>';
}
?>
但什么也没发生。这个文件是有效的,因为如果我输入一些文本,它就会显示但类别没有。我做错了什么?
我想您想循环通过$collection
,但目前您正在循环$array
,在您显示的代码中没有定义。