当前位置: 首页>>代码示例>>PHP>>正文


PHP Varien_Data_Tree_Node::addChild方法代码示例

本文整理汇总了PHP中Varien_Data_Tree_Node::addChild方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Data_Tree_Node::addChild方法的具体用法?PHP Varien_Data_Tree_Node::addChild怎么用?PHP Varien_Data_Tree_Node::addChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Varien_Data_Tree_Node的用法示例。


在下文中一共展示了Varien_Data_Tree_Node::addChild方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _injectLinks

 /**
  * Inject links into the top navigation
  *
  * @param Mage_Core_Model_Resource_Db_Collection_Abstract $items
  * @param Varien_Data_Tree_Node $parentNode
  * @return bool
  */
 protected function _injectLinks($items, $parentNode)
 {
     if (!$parentNode) {
         return false;
     }
     foreach ($items as $item) {
         if (!$item->canIncludeInMenu()) {
             continue;
         }
         $children = $item->getSplashPages();
         if ($children && count($children->addOrderByName()->addFieldToFilter('include_in_menu', 1)->load()) === 0) {
             continue;
         }
         $data = array('name' => $item->getName(), 'id' => $item->getMenuNodeId(), 'url' => $item->getUrl(), 'is_active' => $item->isActive());
         if ($data['is_active']) {
             $parentNode->setIsActive(true);
             $buffer = $parentNode;
             while ($buffer->getParent()) {
                 $buffer = $buffer->getParent();
                 $buffer->setIsActive(true);
             }
         }
         $itemNode = new Varien_Data_Tree_Node($data, 'id', $parentNode->getTree(), $parentNode);
         $parentNode->addChild($itemNode);
         if ($children) {
             $this->_injectLinks($children, $itemNode);
         }
     }
     return true;
 }
开发者ID:Benjamin021,项目名称:magento-attribute-page,代码行数:37,代码来源:Observer.php

示例2: _addCategoriesToMenu

 /**
  * Recursively adds categories to top menu
  *
  * @param Varien_Data_Tree_Node_Collection|array $categories
  * @param Varien_Data_Tree_Node $parentCategoryNode
  * @param Mage_Page_Block_Html_Topmenu $menuBlock
  * @param bool $addTags
  */
 protected function _addCategoriesToMenu($categories, $parentCategoryNode, $menuBlock, $addTags = false)
 {
     $categoryModel = Mage::getModel('catalog/category');
     foreach ($categories as $category) {
         if (!$category->getIsActive()) {
             continue;
         }
         $nodeId = 'category-node-' . $category->getId();
         $categoryModel->setId($category->getId());
         if ($addTags) {
             $menuBlock->addModelTags($categoryModel);
         }
         //check if there is a cms page set in category
         if ($category->getCmsPage()) {
             $categoryUrl = Mage::helper('cms/page')->getPageUrl($category->getCmsPage());
         } else {
             $categoryUrl = Mage::helper('catalog/category')->getCategoryUrl($category);
         }
         $tree = $parentCategoryNode->getTree();
         $categoryData = array('name' => $category->getName(), 'id' => $nodeId, 'url' => $categoryUrl, 'is_active' => $this->_isActiveMenuCategory($category));
         $categoryNode = new Varien_Data_Tree_Node($categoryData, 'id', $tree, $parentCategoryNode);
         $parentCategoryNode->addChild($categoryNode);
         $flatHelper = Mage::helper('catalog/category_flat');
         if ($flatHelper->isEnabled() && $flatHelper->isBuilt(true)) {
             $subcategories = (array) $category->getChildrenNodes();
         } else {
             $subcategories = $category->getChildren();
         }
         $this->_addCategoriesToMenu($subcategories, $categoryNode, $menuBlock, $addTags);
     }
 }
开发者ID:beljic,项目名称:CmsNavigation,代码行数:39,代码来源:Observer.php

示例3: _addCategoriesToMenu

 /**
  * Override Mage_Catalog_Model_Observer _addCategoriesToMenu method to remove the links for the categories having unclickable attribute set
  *
  * @param Varien_Data_Tree_Node_Collection|array $categories
  * @param Varien_Data_Tree_Node $parentCategoryNode
  * @param Mage_Page_Block_Html_Topmenu $menuBlock
  * @param bool $addTags
  */
 protected function _addCategoriesToMenu($categories, $parentCategoryNode, $menuBlock, $addTags = false)
 {
     //Get collection of unclickable category ids in the menu
     $categoryModel = Mage::getModel('catalog/category');
     foreach ($categories as $category) {
         if (!$category->getIsActive()) {
             continue;
         }
         $nodeId = 'category-node-' . $category->getId();
         $categoryModel->setId($category->getId());
         if ($addTags) {
             $menuBlock->addModelTags($categoryModel);
         }
         $tree = $parentCategoryNode->getTree();
         //Set javascript:; as category url if category attribute is unclickable
         $categoryData = array('name' => $category->getName(), 'id' => $nodeId, 'url' => in_array($category->getId(), $this->unClickableIds) ? self::NOLINK : Mage::helper('catalog/category')->getCategoryUrl($category), 'is_active' => $this->_isActiveMenuCategory($category));
         $categoryNode = new Varien_Data_Tree_Node($categoryData, 'id', $tree, $parentCategoryNode);
         $parentCategoryNode->addChild($categoryNode);
         $flatHelper = Mage::helper('catalog/category_flat');
         if ($flatHelper->isEnabled() && $flatHelper->isBuilt(true)) {
             $subcategories = (array) $category->getChildrenNodes();
         } else {
             $subcategories = $category->getChildren();
         }
         $this->_addCategoriesToMenu($subcategories, $categoryNode, $menuBlock, $addTags);
     }
 }
开发者ID:hardanro,项目名称:Monsoon_test,代码行数:35,代码来源:Observer.php

示例4: _addCategoriesToMenu

 /**
  * Recursively adds categories to top menu
  * see Mage_Catalog_Model_Observer::_addCategoriesToMenu()
  * added new category data
  *
  * @param Varien_Data_Tree_Node_Collection|array $categories
  * @param Varien_Data_Tree_Node $parentCategoryNode
  * @param Mage_Page_Block_Html_Topmenu $menuBlock
  * @param bool $addTags
  */
 protected function _addCategoriesToMenu($categories, $parentCategoryNode, $menuBlock, $addTags = false)
 {
     $categoryModel = Mage::getModel('catalog/category');
     foreach ($categories as $category) {
         if (!$category->getIsActive()) {
             continue;
         }
         $nodeId = 'category-node-' . $category->getId();
         $categoryModel->setId($category->getId());
         if ($addTags) {
             $menuBlock->addModelTags($categoryModel);
         }
         $tree = $parentCategoryNode->getTree();
         $categoryData = array('name' => $category->getName(), 'id' => $nodeId, 'url' => Mage::helper('catalog/category')->getCategoryUrl($category), 'is_active' => $this->_isActiveMenuCategory($category), 'category_id' => $category->getId(), 'mm_block_identifier' => $category->getMmBlockIdentifier(), 'mm_image' => $category->getMmImage(), 'mm_turn_on' => $category->getMmTurnOn(), 'mm_turn_images_on' => $category->getMmTurnImagesOn(), 'mm_column_number' => $category->getMmColumnNumber());
         $categoryNode = new Varien_Data_Tree_Node($categoryData, 'id', $tree, $parentCategoryNode);
         $parentCategoryNode->addChild($categoryNode);
         $flatHelper = Mage::helper('catalog/category_flat');
         if ($flatHelper->isEnabled() && $flatHelper->isBuilt(true)) {
             $subcategories = (array) $category->getChildrenNodes();
         } else {
             $subcategories = $category->getChildren();
         }
         $this->_addCategoriesToMenu($subcategories, $categoryNode, $menuBlock, $addTags);
     }
 }
开发者ID:KvantX,项目名称:megamenu,代码行数:35,代码来源:Observer.php

示例5: getCategories

 /**
  * Returns categories with include_in_mega_menu set to yes in Admin
  *
  * @return Varien_Data_Tree_Node_Collection
  */
 public function getCategories()
 {
     $root = Mage::app()->getStore()->getRootCategoryId();
     $tree = Mage::getResourceModel('catalog/category_tree');
     /* @var $tree Mage_Catalog_Model_Resource_Category_Tree */
     $nodes = $tree->loadNode($root);
     $categories = Mage::getModel('catalog/category')->getCollection()->addAttributeToSelect(array('name', 'url_key', 'is_active', 'mega_menu_block', 'mega_menu_sort_order'))->addAttributeToSort('mega_menu_sort_order', 'ASC')->addAttributeToFilter('include_in_mega_menu', 1);
     foreach ($categories as $category) {
         $categoryData = $this->getCategoryData($category);
         $categoryNode = new Varien_Data_Tree_Node($categoryData, 'id', $tree, $nodes);
         $categoryChildren = $this->getSubcategories($category);
         foreach ($categoryChildren as $child) {
             $childData = $this->getCategoryData($child);
             $childCategoryNode = new Varien_Data_Tree_Node($childData, 'id', $tree, $nodes);
             $categoryNode->addChild($childCategoryNode);
         }
         $nodes->addChild($categoryNode);
     }
     return $nodes->getChildren();
 }
开发者ID:lgilders,项目名称:MegaMenu,代码行数:25,代码来源:Data.php

示例6: _addPagesToMenu

 /**
  * Recursively adds CMS pages to top menu
  *
  * @param Varien_Data_Tree_Node_Collection|array $pages
  * @param Varien_Data_Tree_Node $parentPageNode
  * @param Mage_Page_Block_Html_Topmenu $menuBlock
  * @param bool $addTags
  */
 protected function _addPagesToMenu($pages, $parentPageNode, $menuBlock, $addTags = false)
 {
     $pageModel = Mage::getModel('cms/page');
     foreach ($pages as $page) {
         if (!$page->getIsActive() || !$page->getIncludeInMenu() || !$this->_isAllowed($page)) {
             continue;
         }
         $nodeId = 'page-node-' . $page->getId();
         $pageModel->setId($page->getId());
         if ($addTags) {
             $menuBlock->addModelTags($pageModel);
         }
         $tree = $parentPageNode->getTree();
         $pageData = array('name' => $page->getTitle(), 'id' => $nodeId, 'url' => $page->getUrl(), 'is_active' => $this->_isActiveMenuPage($page));
         $pageNode = new Varien_Data_Tree_Node($pageData, 'id', $tree, $parentPageNode);
         $parentPageNode->addChild($pageNode);
         $children = $page->getChildren();
         if (Mage::helper('cms/page')->isPermissionsEnabled($this->_helper->getStore())) {
             $children->addPermissionsFilter($this->_helper->getCustomerGroupId());
         }
         $this->_addPagesToMenu($children, $pageNode, $menuBlock, $addTags);
     }
 }
开发者ID:technomagegithub,项目名称:olgo.nl,代码行数:31,代码来源:Observer.php

示例7: _addCategoriesToMenu

 /**
  * Recursively adds categories to top menu
  *
  * @param Varien_Data_Tree_Node_Collection|array $categories
  * @param Varien_Data_Tree_Node $parentCategoryNode
  */
 protected function _addCategoriesToMenu($categories, $parentCategoryNode)
 {
     foreach ($categories as $category) {
         if (!$category->getIsActive()) {
             continue;
         }
         $nodeId = 'category-node-' . $category->getId();
         $tree = $parentCategoryNode->getTree();
         $categoryData = array('name' => $category->getName(), 'id' => $nodeId, 'url' => Mage::helper('catalog/category')->getCategoryUrl($category), 'is_active' => $this->_isActiveMenuCategory($category));
         $categoryNode = new Varien_Data_Tree_Node($categoryData, 'id', $tree, $parentCategoryNode);
         $parentCategoryNode->addChild($categoryNode);
         if (Mage::helper('catalog/category_flat')->isEnabled()) {
             $subcategories = (array) $category->getChildrenNodes();
         } else {
             $subcategories = $category->getChildren();
         }
         $this->_addCategoriesToMenu($subcategories, $categoryNode);
     }
 }
开发者ID:smilcent,项目名称:bugathon_march_2013,代码行数:25,代码来源:Observer.php

示例8: _injectLinks

 /**
  * Inject links into the top navigation
  *
  * @param Fishpig_Wordpress_Model_Resource_Menu_Item_Collection $items
  * @param Varien_Data_Tree_Node $parentNode
  * @return bool
  */
 protected function _injectLinks($items, $parentNode)
 {
     if (!$parentNode) {
         return false;
     }
     foreach ($items as $item) {
         try {
             $nodeId = 'wp-node-' . $item->getId();
             $data = array('name' => $item->getLabel(), 'id' => $nodeId, 'url' => $item->getUrl(), 'is_active' => $item->isItemActive());
             if ($data['is_active']) {
                 $parentNode->setIsActive(true);
                 $buffer = $parentNode;
                 while ($buffer->getParent()) {
                     $buffer = $buffer->getParent();
                     $buffer->setIsActive(true);
                 }
             }
             $itemNode = new Varien_Data_Tree_Node($data, 'id', $parentNode->getTree(), $parentNode);
             $parentNode->addChild($itemNode);
             if (count($children = $item->getChildrenItems()) > 0) {
                 $this->_injectLinks($children, $itemNode);
             }
         } catch (Exception $e) {
             Mage::helper('wordpress')->log($e->getMessage());
         }
     }
     return true;
 }
开发者ID:linusshops,项目名称:mirror-connect20-fishpig-wordpress-integration,代码行数:35,代码来源:Menu.php

示例9: _addCmsPagesToMenu

 /**
  * Recursively adds cms pages to top menu
  *
  * @param JR_CleverCms_Model_Resource_Cms_Page_Collection $cmsPages
  * @param Varien_Data_Tree_Node $parentNode
  * @param Mage_Page_Block_Html_Topmenu $menuBlock
  * @param bool $addTags
  */
 protected function _addCmsPagesToMenu($cmsPages, $parentNode, $menuBlock, $addTags = false)
 {
     foreach ($cmsPages as $cmsPage) {
         /** @var JR_CleverCms_Model_Cms_Page $cmsPage */
         $nodeId = 'cms-node-' . $cmsPage->getId();
         if ($addTags && method_exists($menuBlock, 'addModelTags')) {
             $menuBlock->addModelTags($cmsPage);
         }
         $tree = $parentNode->getTree();
         $nodeData = array('name' => $cmsPage->getTitle(), 'id' => $nodeId, 'class' => $cmsPage->getIdentifier(), 'url' => $cmsPage->getUrl(), 'is_active' => $this->_isActiveMenuCmsPage($cmsPage));
         $categoryNode = new Varien_Data_Tree_Node($nodeData, 'id', $tree, $parentNode);
         $parentNode->addChild($categoryNode);
         $this->_addCmsPagesToMenu($this->_getChildren($cmsPage), $categoryNode, $menuBlock, $addTags);
     }
 }
开发者ID:smart-devs,项目名称:magento-clever-cms,代码行数:23,代码来源:Observer.php

示例10: _addCategoriesToMenu

 /**
  * Recursively adds categories to top menu
  *
  * @param Varien_Data_Tree_Node_Collection|array $categories
  * @param Varien_Data_Tree_Node $parentCategoryNode
  * @param Mage_Page_Block_Html_Topmenu $menuBlock
  * @param bool $addTags
  */
 protected function _addCategoriesToMenu($categories, $parentCategoryNode, $menuBlock, $addTags = false)
 {
     $categoryModel = Mage::getModel('catalog/category');
     foreach ($categories as $category) {
         if (!$category->getIsActive()) {
             continue;
         }
         $nodeId = 'category-node-' . $category->getId();
         $categoryModel->setId($category->getId());
         if ($addTags) {
             $menuBlock->addModelTags($categoryModel);
         }
         $tree = $parentCategoryNode->getTree();
         $categoryData = array('name' => $category->getName(), 'id' => $nodeId, 'url' => Mage::helper('catalog/category')->getCategoryUrl($category), 'is_active' => $this->_isActiveMenuCategory($category), 'links' => $category->getData('links'), 'image' => $category->getImageUrl('image'), 'thumbnail' => Mage::getResourceModel('catalog/category')->getAttributeRawValue($category->getId(), "thumbnail", Mage::app()->getStore()->getId()), 'getLevel' => $category->getLevel(), 'iconimagepath' => Mage::getResourceModel('catalog/category')->getAttributeRawValue($category->getId(), "iconimagepath", Mage::app()->getStore()->getId()));
         $categoryNode = new Varien_Data_Tree_Node($categoryData, 'id', $tree, $parentCategoryNode);
         $parentCategoryNode->addChild($categoryNode);
         $flatHelper = Mage::helper('catalog/category_flat');
         if ($flatHelper->isEnabled() && $flatHelper->isBuilt(true)) {
             $subcategories = (array) $category->getChildrenNodes();
         } else {
             $subcategories = $category->getChildren();
         }
         $this->_addCategoriesToMenu($subcategories, $categoryNode, $menuBlock, $addTags);
     }
 }
开发者ID:Madhurabhat,项目名称:test,代码行数:33,代码来源:Observer.php


注:本文中的Varien_Data_Tree_Node::addChild方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。