Magento 静态页面菜单

Magento static pages menu(Magento 静态页面菜单)
本文介绍了Magento 静态页面菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我想制作一个菜单,可以动态显示来自 CMS 的活动静态页面;例如,如果在我的 CMS 中我有这些页面:

  • 关于我们(已启用)
  • 航运和退款(禁用)
  • 条款和条件(已启用)
  • 联系人(已启用)

然后菜单看起来像:

关于我们 |条款和条件 |联系人

我需要一些关于如何开始的提示;也许之前有人已经这样做了?

解决方案

Dougle非常感谢,真的很有帮助!

联邦在 Magento CMS 中,您可以制作只能使用其 IDENTIFIER 访问的静态页面;我想要的是以某种方式制作一个菜单,该菜单将自动显示 ACTIVE(启用)静态页面;如果您将状态设置为禁用,则不应出现在菜单中;

这是我使用的代码,注意有 IF $PageData['identifier']!='no-route'; no-rute 是 404 页面,所以我不需要它在菜单中,但必须启用,以便 Magento 将 404 错误重定向到此页面;

<?php $collection = Mage::getModel('cms/page')->getCollection()->addStoreFilter(Mage::app()->getStore()->getId());?><?php $collection->getSelect()-> where('is_active = 1');?><ul><?php foreach ($collection as $page): ?><?php $PageData = $page->getData();?><?php if($PageData['identifier']!='no-route') { ?><li><a href="/<?php echo $PageData['identifier']?>"><?php echo $PageData['title'] ?></a><?php } ?><?php endforeach;?>

I want to make a menu that will dynamically show the active static pages from CMS; for example if in my CMS I have these pages:

  • About Us (enabled)
  • Shipping & Refund (disabled)
  • Terms and Conditions (enabled)
  • Contacts (enabled)

then the menu would look like:

About US | Terms and Conditions | Contacts

I need just a few tips on how to get started; maybe somebody has already done this before?

解决方案

Dougle thanks a lot, that was really helpful!

Fede in Magento CMS you can make static pages that you can only access using its IDENTIFIER; what I wanted is somehow make a menu that will automatically display the ACTIVE (enabled) static pages; and if you set status to Disable it should not be in the menu;

here is the code i used, note there is IF $PageData['identifier']!='no-route'; no-rute is the 404 page, so i don't need it in the menu, but it must be enabled so Magento redirects 404 errors to this page;

<div>
    <?php $collection = Mage::getModel('cms/page')->getCollection()->addStoreFilter(Mage::app()->getStore()->getId());?>
    <?php  $collection->getSelect()
          ->where('is_active = 1'); ?>
    <ul>
    <?php foreach ($collection as $page): ?>
      <?php $PageData = $page->getData(); ?>
      <?php if($PageData['identifier']!='no-route') { ?>
      <li>
        <a href="/<?php echo $PageData['identifier']?>"><?php echo $PageData['title'] ?></a>
      </li>
      <?php } ?>
    <?php endforeach; ?>
</div>

这篇关于Magento 静态页面菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

In PHP how can you clear a WSDL cache?(在 PHP 中如何清除 WSDL 缓存?)
failed to open stream: HTTP wrapper does not support writeable connections(无法打开流:HTTP 包装器不支持可写连接)
Stop caching for PHP 5.5.3 in MAMP(在 MAMP 中停止缓存 PHP 5.5.3)
Caching HTTP responses when they are dynamically created by PHP(缓存由 PHP 动态创建的 HTTP 响应)
Memcached vs APC which one should I choose?(Memcached 与 APC 我应该选择哪一个?)
What is causing quot;Unable to allocate memory for poolquot; in PHP?(是什么导致“无法为池分配内存?在 PHP 中?)