【问题标题】:Dynamic Footer Links Magento动态页脚链接 Magento
【发布时间】:2012-05-07 11:31:54
【问题描述】:

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

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

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

【问题讨论】:

    标签: php magento hyperlink content-management-system


    【解决方案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 ?>
    

    【讨论】:

      【解决方案2】:

      使用以下代码通过 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 ?>
      

      它只列出根类别下的主要类别

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-07-13
        • 2015-09-23
        • 2014-09-12
        • 1970-01-01
        • 1970-01-01
        • 2010-11-18
        • 1970-01-01
        • 2015-11-27
        相关资源
        最近更新 更多