动态页脚链接Magento

时间:2012-05-07 11:31:54

标签: php magento hyperlink content-management-system

您好,我在Magento 1.6.2.0中有一个magento网站。我想根据我创建的类别设置我的页脚链接。我在我的'footer cms'中添加了一个链接

<li><a href="#">Living Room Furniture</a></li>

如何使用类别ID /名称放置链接(href)?

2 个答案:

答案 0 :(得分:1)

在footer.phtml中使用以下代码

  <?php $helper = $this->helper('catalog/category') ?>
    <?php foreach ($helper->getStoreCategories() as $_category): ?> 
    <a href="<?php echo Mage::getModel('catalog/category')->setData($_category->getData())->getUrl(); ?>" title="<?php echo $_category->getName() ?>"><?php echo $_category->getName() ?></a>
    <?php endforeach ?>

答案 1 :(得分:1)

使用以下代码通过CMS调用模板文件。

{{block type="catalog/navigation" template="folder/filename.phtml"}}

在该文件中,您可以执行代码列出类别。

<?php $_helper = $this->helper('catalog/category') ?>
<?php foreach ($_helper->getStoreCategories() as $_category): ?> 
    <a href="<?php echo Mage::getModel('catalog/category')->setData($_category->getData())->getUrl(); ?>" title="<?php echo $_category->getName() ?>"><?php echo $_category->getName() ?></a>
<?php endforeach ?>

它仅列出根类别

下的主要类别