1
我已經創建了一個左側邊欄導航模板,可以通過兩種類別(動態)和CMS頁面手動添加(請參見下面的代碼)和I已經設法獲得活動狀態,但我最好是動態地拉動頁面,然後添加活動狀態。有任何想法嗎?提前致謝。動態檢索CMS頁面並基於Magento中的當前頁面標識符添加活動狀態
<?php $_menu = $this->renderCategoriesMenuHtml(0,'level-top') ?>
<?php if($_menu): ?>
<?php
$current_page = '';
/*
* Check to see if its a CMS page
* if it is then get the page identifier
*/
if(Mage::app()->getFrontController()->getRequest()->getRouteName() == 'cms'):
$current_page = Mage::getSingleton('cms/page')->getIdentifier();
endif
?>
<nav class="nav-container">
<ul id="nav">
<?php echo $_menu; ?>
<li <?php if ($current_page == 'home') { echo 'class="active"'; } else { echo 'class="home"'; } ?>><a href="<?php echo $this->getUrl('home')?>"><span><?php echo $this->__('Home') ?></span></a></li>
<li <?php if ($current_page == 'about') { echo 'class="active"'; } else { echo 'class="about"'; } ?>><a href="<?php echo $this->getUrl('about')?>"><span><?php echo $this->__('About') ?></span></a></li>
<li <?php if ($current_page == 'faqs') { echo 'class="active"'; } else { echo 'class="faqs"'; } ?>><a href="<?php echo $this->getUrl('faqs')?>"><span><?php echo $this->__('FAQS') ?></span></a></li>
<li <?php if ($current_page == 'contacts') { echo 'class="active"'; } else { echo 'class="contacts"'; } ?>><a href="<?php echo $this->getUrl('contacts')?>"><span><?php echo $this->__('Contact Us') ?></span></a></li>
<li <?php if ($current_page == 'artworks') { echo 'class="active"'; } else { echo 'class="artworks"'; } ?>><a href="<?php echo $this->getUrl('artworks')?>"><span><?php echo $this->__('Artworks') ?></span></a></li>
<li <?php if ($current_page == 'how-it-works') { echo 'class="active"'; } else { echo 'class="how-it-works"'; } ?>><a href="<?php echo $this->getUrl('how-it-works')?>"><span><?php echo $this->__('How it Works') ?></span></a></li>
</ul>
</nav>
<?php endif ?>