6

I can't seem to find an example of how to use the Enterprise Edition CMS Hierarchy functionality within my theme. The admin interface is simple enough, but its useless if I can't access that information to dynamically build menus! I've contacted Magento directly and they have not been able to provide me any kind of documentation and told me that they "do not support theme development." Awesome :)

Can someone please help me out? All I really need is that little piece of code that will give me either an object or an array with the CMS hierarchy info, page titles and links and I'll be good to go. Thanks!

2

I have been working on getting this data for some time, finally managed to devise a solution. Here's the code I used.

<?php
$_menu = Mage::app()->getLayout()->createBlock('enterprise_cms/hierarchy_menu');
$_menu->setNodeId(1); //change to the id number of the desired node
$_menu->_construct(); //calling construct method again after setting node
$_tree = $_menu->getTree();
echo $_menu->drawMenu($_tree,1); //this number should match the one above

//show the full collection
//echo "<pre>";print_r($_tree);echo "</pre>";

//uncomment the following block of code for detailed debug info
/*foreach ($_tree as $_nodes) {
    foreach($_nodes as $_slice){
        print_r($_slice->getData());
        echo "<br /><br />";
    }
}*/

?>
  • 1
    Please note that you cannot execute _construct() since it's a static method. You could better make use of the registry instead: Mage::register('current_cms_hierarchy_node', $node, true); $menu = Mage::app()->getLayout()->createBlock('enterprise_cms/hierarchy_menu'); $tree = $menu->getTree(); var_dump($tree); – Giel Berkers Nov 24 '14 at 11:25
4

There is a block Enterprise_Cms_Block_Hierarchy_Menu which generates output for hierachical menus. You can even get the contents via the getTree method and build the output on your own.

  • I think I understand what you're saying conceptually, but I'm new to Magento and need a little more hand holding. How would I go about using the getTree method from within my footer.phtml file? – Jake A. Smith Jan 30 '13 at 13:50
  • What you need to do is load the block, either by defining it in layout.xml or get it via Mage:app()->getLayout()->createBlock('enterprise_cms/hierachy_menu'). Then you can directly access the getTree method. – Tobias Jan 30 '13 at 14:20
  • 1
    Mage::app()->getLayout()->createBlock('enterprise_cms/hierarchy_menu'); is the working call. There are some typos in the above comment. – DWils Feb 20 '14 at 23:25

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.