在自定义主题中使用EE CMS层次结构
-
16-10-2019 - |
题
我似乎找不到如何在主题中使用企业版CMS层次结构功能的示例。管理界面足够简单,但是如果我无法访问该信息来动态构建菜单,则无用!我已经直接联系了Magento,他们无法为我提供任何形式的文档,并告诉我他们“不支持主题开发”。惊人的 :)
有人可以帮我吗?我真正需要的是那个小的代码,它将为我提供一个带有CMS层次结构信息,页面标题和链接的对象或数组,我将很高兴。谢谢!
解决方案
我一直在努力获取这些数据一段时间,最终设法设计了一个解决方案。这是我使用的代码。
<?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 />";
}
}*/
?>
其他提示
有一个块Enterprise_CMS_BLOCK_HIERARCHY_MENU,它为Hierachical Menus生成输出。您甚至可以通过GetTree方法获得内容,并自行构建输出。