1
votes

I am new to Magento and completely lost. I have a problem in assigning CMS pages to navigation bar.

Say from manage categories I am creating a sub category contact us & want to show a cms page named contact us in the frontend when clicking on that contact us menu. What do I have to do for that? And after clicking on the menu it should go to a page like mysite.com/contact-us.html. It is going there but it's showing there are no products matching the selection.

2

2 Answers

0
votes

You can use this code to get all cms pages dynamically in navigation

Place this code in header file below topcontainer

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

Note change this part of code "/magento/index.php/" according to your domain

0
votes

Create a category

Create your cms page

Create an URL rewrite that redirects your category to your cms page.

Thus, you will have a link in the menu and that link would redirect to your CMS page.

Example:

Category:

  • Name: About Us

  • URL Key: about-us

  • ID: 4

CMS page:

  • Name: About Us

  • URL Key: about-us

URL Rewrite:

  • Type: Custom

  • ID Path: about-us

  • Request path: catalog/category/view/id/4

  • Target path: about-us/

  • Redirect: Permanent