1

I have a phtml template that I'd like to add the CMS nav menu to. The page is added through the hierarchy but when clicked it renders without the CMS navigation on the left side (the page is using the 2 column-left template). The others are standard CMS Pages created through the Admin so they work fine.

Does anyone know where I can find the block to add to local.xml? Everywhere I've looked on the internet is about how to add a page to CMS, not add the CMS component to the page. Any help would be greatly appreciated. Thanks!

1

Do you want to show cms links on the left side bar? if yes do this:

create page cms-nav.phtml in yourtemplate/template/cms

<div class="CmsNav">
  <?php $collection = Mage::getModel('cms/page')->getCollection()->addStoreFilter(Mage::app()->getStore()->getId());?>
  <?php  $collection->getSelect()
    ->where('is_active = 1')
    ->order('main_table.sort_order ASC'); ?>
  <ul>
    <?php foreach ($collection as $page): ?>
      <?php $PageData = $page->getData(); ?>
      <?php if($PageData['identifier']!='no-route') : ?>
      <li <?php if(Mage::getSingleton('cms/page')->getIdentifier()  ==  $PageData['identifier']): echo 'class="active"'; endif; ?>>
        <a href="<?php echo $this->getBaseUrl() . $PageData['identifier']?>" title="<?php echo $PageData['title'] ?>"><?php echo $PageData['title'] ?></a>
      </li>
      <?php endif ?>
    <?php endforeach; ?>
  </ul>

</div>

In your local.xml add this :

<cms_page>
        <reference name="content">
            <action method="setTemplate"><template>page/2columns-left.phtml</template></action>
        </reference>
        <reference name="left">
            <block type="core/template" as="cms-nav" name="cms-nav" template="cms/cms-nav.phtml"/>
        </reference>

</cms_page>

This code will create a list on the left side bar for all the CMS pages on your site.

  • The left part didn't work but it got the menu on the page. I can work from here. Thank you! – dshamis317 Oct 14 '14 at 14:00
  • Worked fine here. – joaogdesigner Apr 4 '17 at 1:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.