Frage

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!

War es hilfreich?

Lösung

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit magento.stackexchange
scroll top