Created
April 11, 2013 21:16
-
-
Save myinitialsaretk/5367245 to your computer and use it in GitHub Desktop.
Magento CMS Hierarchy Stub. This is mostly useless, but just saving for myself for reference.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="nav-container sidebar-nav"> | |
<ul class="nav nav-list"> | |
<?php | |
$currentPage = $this->getHelper('cms/page')->getPage()->getPageId(); | |
$currentPageParent = ''; | |
$outputNodes = Array(); | |
$collection = Mage::getModel('enterprise_cms/hierarchy_node')->getCollection()->joinCmsPage()->setTreeOrder(); | |
foreach ($collection as $item) { | |
if ($item->getPageId() == $currentPage) | |
$currentPageParent = $item->getParentNodeId(); | |
} | |
foreach ($collection as $item) { | |
if ($item->getParentNodeId() == $currentPageParent) { // This Page Shares a Parent | |
/* @var $item Enterprise_Cms_Model_Hierarchy_Node */ | |
$node = array( | |
'node_id' => $item->getId(), | |
'parent_node_id' => $item->getParentNodeId(), | |
'label' => $item->getLabel(), | |
'page_exists' => (bool)$item->getPageExists(), | |
'page_id' => $item->getPageId(), | |
'url' => $item->getUrl() | |
); | |
if ($item->getPageId() == $currentPage) | |
$node['current'] = true; | |
$outputNodes[] = $node; | |
} | |
} | |
if ($outputNodes) { | |
foreach($outputNodes as $node) { | |
if ($node['current']) | |
echo '<li class="active" ><a href="' . $node['url'] . '"><span>' . $node['label'] . '</span></li>'; | |
else | |
echo '<li><a href="' . $node['url'] . '"><span>' . $node['label'] . '</span></li>'; | |
} | |
} | |
?> | |
</ul> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment