本文整理汇总了PHP中Varien_Event_Observer::getMenu方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Event_Observer::getMenu方法的具体用法?PHP Varien_Event_Observer::getMenu怎么用?PHP Varien_Event_Observer::getMenu使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Varien_Event_Observer
的用法示例。
在下文中一共展示了Varien_Event_Observer::getMenu方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addToTopmenu
public function addToTopmenu(Varien_Event_Observer $observer)
{
$menu = $observer->getMenu();
$tree = $menu->getTree();
$node = new Varien_Data_Tree_Node(array('name' => 'News', 'id' => 'news', 'url' => Mage::getUrl('news/news/index/')), 'id', $tree, $menu);
$menu->addChild($node);
}
示例2: beforeTopmenuHtml
/**
* Adds CMS pages to top menu
*
* @param Varien_Event_Observer $observer
*/
public function beforeTopmenuHtml(Varien_Event_Observer $observer)
{
if (Mage::getStoreConfigFlag('bubble_cmstree/general/include_in_menu')) {
$block = $observer->getEvent()->getBlock();
$block->addCacheTag(Mage_Cms_Model_Page::CACHE_TAG);
$this->_addPagesToMenu($this->_helper->getStoreCmsPages(), $observer->getMenu(), $block, true);
}
}
示例3: addToTopmenu
public function addToTopmenu(Varien_Event_Observer $observer)
{
$configStatus = Mage::helper('bforward_special_price')->getExtensionStatus();
if ($configStatus) {
$fieldName = Mage::helper('bforward_special_price')->getItemName();
$menu = $observer->getMenu();
$tree = $menu->getTree();
$node = new Varien_Data_Tree_Node(array('name' => $fieldName, 'id' => 'special_price', 'url' => Mage::getUrl('special_price')), 'id', $tree, $menu);
$menu->addChild($node);
}
}
示例4: pageBlockHtmlTopmenuGethtmlBefore
/**
* Hide the catalog navigation to logged out visitors if the feature is configured.
*
* @param Varien_Event_Observer $observer
*/
public function pageBlockHtmlTopmenuGethtmlBefore(Varien_Event_Observer $observer)
{
if (Mage::helper('logincatalog')->shouldHideCategoryNavigation()) {
/** @var $menu Varien_Data_Tree_Node */
$menu = $observer->getMenu();
foreach ($menu->getChildren() as $key => $node) {
if (strpos($key, 'category-') === 0) {
$menu->removeChild($node);
}
}
}
}
示例5: cmsPagesToTopmenu
/**
* Add CMS pages link to top navigation menu
* @param Varien_Event_Observer $observer
*/
public function cmsPagesToTopmenu(Varien_Event_Observer $observer)
{
$menu = $observer->getMenu();
$tree = $menu->getTree();
$cmsPagesId = explode(',', Mage::getStoreConfig('bforward_menu/form/cms_pages'));
$promotionOrder = 1;
$collection = Mage::getModel('cms/page')->getCollection()->addFieldToFilter('page_id', array('in' => $cmsPagesId));
foreach ($collection as $page) {
$node = new Varien_Data_Tree_Node(array('name' => $page->getTitle(), 'id' => $page->getIdentifier(), 'url' => Mage::getUrl($page->getIdentifier())), 'id', $tree, $menu);
$menu->addChild($node);
$promotionOrder++;
}
}
示例6: addNavigationLink
public function addNavigationLink(Varien_Event_Observer $observer)
{
/** @var Styla_Connect_Helper_Config $configHelper */
$configHelper = Mage::helper('styla_connect/config');
if (!$configHelper->isNavigationLinkEnabled()) {
return;
}
$menu = $observer->getMenu();
$tree = $menu->getTree();
$magazineUrl = $configHelper->getFullMagazineUrl();
$magazineMenuNode = new Varien_Data_Tree_Node(array('name' => $configHelper->getNavigationLinkLabel(), 'id' => 'styla-magazine', 'url' => $magazineUrl), 'id', $tree, $menu);
$menu->addChild($magazineMenuNode);
}
示例7: customizeTopMenu
/**
* customizeTopMenu observer - called on page_block_html_topmenu_gethtml_before in config.xml
*
* @param Varien_Event_Observer $observer
*/
public function customizeTopMenu(Varien_Event_Observer $observer)
{
$block = $observer->getEvent()->getBlock();
$block->addCacheTag(Mage_Catalog_Model_Category::CACHE_TAG);
//Get collection of unclickable category ids in the menu
if (null !== Mage::getModel('catalog/resource_eav_attribute')->loadByCode('catalog_category', 'unclickable_menu_category')->getId()) {
$collection = Mage::getModel('catalog/category')->getCollection();
$collection->addAttributeToSelect('*');
$collection->addAttributeToFilter('unclickable_menu_category', array('eq' => 1));
$this->unClickableIds = $collection->getAllIds();
}
$this->_addCategoriesToMenu(Mage::helper('catalog/category')->getStoreCategories(), $observer->getMenu(), $block, true);
}
示例8: addToTopMenu
public function addToTopMenu(Varien_Event_Observer $observer)
{
$menu = $observer->getMenu();
$tree = $menu->getTree();
$node = new Varien_Data_Tree_Node(array('name' => 'BRANDS', 'id' => 'brands', 'url' => Mage::getUrl() . 'brand/'), 'id', $tree, $menu);
$menu->addChild($node);
$collection = Mage::getModel('bluecom_branddirectory/brand')->getCollection()->addFieldToFilter('visibility', BlueCom_BrandDirectory_Model_Brand::VISIBILITY_DIRECTORY)->setOrder('entity_id', 'ASC');
foreach ($collection as $brand) {
$tree = $node->getTree();
$data = array('name' => $brand->getName(), 'id' => 'brand-node-' . $brand->getId(), 'url' => Mage::getUrl() . 'brand/index/view/url/' . $brand->getUrlKey());
$subNode = new Varien_Data_Tree_Node($data, 'id', $tree, $node);
$node->addChild($subNode);
}
}
示例9: addToTopmenu
public function addToTopmenu(Varien_Event_Observer $observer)
{
$menu = $observer->getMenu();
$tree = $menu->getTree();
$node = new Varien_Data_Tree_Node(array('name' => 'Categories', 'id' => 'categories', 'url' => Mage::getUrl()), 'id', $tree, $menu);
$menu->addChild($node);
// Children menu items
$collection = Mage::getResourceModel('catalog/category_collection')->setStore(Mage::app()->getStore())->addIsActiveFilter()->addNameToResult()->setPageSize(3);
foreach ($collection as $category) {
$tree = $node->getTree();
$data = array('name' => $category->getName(), 'id' => 'category-node-' . $category->getId(), 'url' => $category->getUrl());
$subNode = new Varien_Data_Tree_Node($data, 'id', $tree, $node);
$node->addChild($subNode);
}
}
示例10: addCmsToTopmenuItems
/**
* Adds CMS hierarchy menu item to top menu
*
* @param Varien_Event_Observer $observer
*/
public function addCmsToTopmenuItems(Varien_Event_Observer $observer)
{
/**
* @var $topMenuRootNode Varien_Data_Tree_Node
*/
$topMenuRootNode = $observer->getMenu();
// $cmsPages = Mage::getModel('cms/page')->getCollection();
$cmsPages = Mage::getResourceModel('cms/page_collection');
//$nodes = $hierarchyModel->getNodesData();
$tree = $topMenuRootNode->getTree();
$nodesFlatList = array($topMenuRootNode->getId() => $topMenuRootNode);
//$nodeModel = Mage::getModel('enterprise_cms/hierarchy_node');
$cmsPageModel = Mage::getModel('cms/page');
foreach ($cmsPages as $cmsPage) {
//$parentNode = null;
$cmsPageData = $cmsPageModel->load($cmsPage->getId());
//check if CMS goes to root
if ($cmsPageData->getParentNodeId()) {
if ($cmsPageData->getParentNodeId() == MageD_CmsNavigation_Helper_Data::ROOT_NAVIGATION_IDENTIFIER) {
$parentNodeId = $topMenuRootNode->getId();
$parentNode = isset($nodesFlatList[$parentNodeId]) ? $nodesFlatList[$parentNodeId] : null;
} else {
foreach ($topMenuRootNode->getAllChildNodes() as $fl) {
if ($fl['id'] == 'category-node-' . $cmsPageData->getParentNodeId()) {
$parentNode = $fl;
}
if ($fl['id'] == $cmsPageData->getParentNodeId()) {
$parentNode = $fl;
}
}
}
$menuNodeId = 'cms-node-' . $cmsPage->getId();
$menuNodeData = array('name' => $cmsPageData->getData('title'), 'id' => $cmsPageData->getData('identifier'), 'url' => Mage::getBaseUrl() . $cmsPageData->getData('identifier'), 'is_active' => 1);
$menuNode = new Varien_Data_Tree_Node($menuNodeData, 'id', $tree, $parentNode);
if ($parentNode) {
$parentNode->addChild($menuNode);
} else {
Mage::log('CMS Page: ' . $cmsPageData->getData('identifier') . '. Parent node not found in menu: ' . $cmsPageData->getParentNodeId() . '.');
}
$nodesFlatList[$menuNodeId] = $menuNode;
}
}
return;
}
示例11: addToTopmenu
public function addToTopmenu(Varien_Event_Observer $observer)
{
if (Mage::helper('formbuilder')->showLinkinTopmenu()) {
$menu = $observer->getMenu();
$tree = $menu->getTree();
$node = new Varien_Data_Tree_Node(array('name' => 'Formbuilder', 'id' => 'formbuilder', 'url' => Mage::getUrl('formbuilder')), 'id', $tree, $menu);
$menu->addChild($node);
// Children menu items
$collection = Mage::getModel('formbuilder/forms')->getCollection();
$collection->addFieldToFilter('status', array('eq' => 1));
$collection->addFieldToFilter('in_menu', array('eq' => 1));
foreach ($collection as $category) {
$tree = $node->getTree();
$data = array('name' => $category->getTitle(), 'id' => 'category-node-' . $category->getFormsIndex(), 'url' => Mage::getUrl('formbuilder/index/view') . 'id/' . $category->getFormsIndex());
$subNode = new Varien_Data_Tree_Node($data, 'id', $tree, $node);
$node->addChild($subNode);
}
}
}
示例12: addCatalogToTopmenuItems
/**
* Adds catalog categories to top menu
*
* @param Varien_Event_Observer $observer
*/
public function addCatalogToTopmenuItems(Varien_Event_Observer $observer)
{
$block = $observer->getEvent()->getBlock();
$block->addCacheTag(Mage_Catalog_Model_Category::CACHE_TAG);
$this->_addCategoriesToMenu(Mage::helper('catalog/category')->getStoreCategories(), $observer->getMenu(), $block, true);
}
示例13: addCatalogToTopmenuItems
/**
* Adds catalog categories to top menu
*
* @param Varien_Event_Observer $observer
*/
public function addCatalogToTopmenuItems(Varien_Event_Observer $observer)
{
$this->_addCategoriesToMenu(Mage::helper('catalog/category')->getStoreCategories(), $observer->getMenu());
}
示例14: addCmsToTopmenuItems
/**
* Adds CMS hierarchy menu item to top menu
*
* @param Varien_Event_Observer $observer
*/
public function addCmsToTopmenuItems(Varien_Event_Observer $observer)
{
/**
* @var $topMenuRootNode Varien_Data_Tree_Node
*/
$topMenuRootNode = $observer->getMenu();
$hierarchyModel = Mage::getModel('enterprise_cms/hierarchy_node', array('scope' => Enterprise_Cms_Model_Hierarchy_Node::NODE_SCOPE_STORE, 'scope_id' => Mage::app()->getStore()->getId()))->getHeritage();
$nodes = $hierarchyModel->getNodesData();
$tree = $topMenuRootNode->getTree();
$nodesFlatList = array($topMenuRootNode->getId() => $topMenuRootNode);
$nodeModel = Mage::getModel('enterprise_cms/hierarchy_node');
foreach ($nodes as $node) {
$nodeData = $nodeModel->load($node['node_id']);
if (!$nodeData || $nodeData->getParentNodeId() == null && !$nodeData->getTopMenuVisibility() || $nodeData->getParentNodeId() != null && $nodeData->getTopMenuExcluded() || $nodeData->getPageId() && !$nodeData->getPageIsActive()) {
continue;
}
$menuNodeId = 'cms-hierarchy-node-' . $node['node_id'];
$menuNodeData = array('name' => $nodeData->getLabel(), 'id' => $menuNodeId, 'url' => $nodeData->getUrl(), 'is_active' => $this->_isCmsNodeActive($nodeData));
$parentNodeId = !isset($node['parent_node_id']) ? $topMenuRootNode->getId() : 'cms-hierarchy-node-' . $node['parent_node_id'];
$parentNode = isset($nodesFlatList[$parentNodeId]) ? $nodesFlatList[$parentNodeId] : null;
if (!$parentNode) {
continue;
}
$menuNode = new Varien_Data_Tree_Node($menuNodeData, 'id', $tree, $parentNode);
$parentNode->addChild($menuNode);
$nodesFlatList[$menuNodeId] = $menuNode;
}
}
示例15: addCatalogToTopmenuItems
/**
* @param Varien_Event_Observer $event
*/
public function addCatalogToTopmenuItems(Varien_Event_Observer $event)
{
$block = $event->getEvent()->getBlock();
$block->addCacheTag(Mage_Catalog_Model_Category::CACHE_TAG);
Mage::getModel('bennoislost_easynavigation/catalog_category_navigation_add')->addCategoriesToMenu(Mage::helper('catalog/category')->getStoreCategories(), $event->getMenu(), $block, true);
}