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


PHP Varien_Data_Tree_Node类代码示例

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


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

示例1: _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

示例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: _drawTwoLevelMenu

 /**
  * @param Varien_Data_Tree_Node $menuTree
  * @return string
  */
 protected function _drawTwoLevelMenu(Varien_Data_Tree_Node $menuTree)
 {
     $children = $menuTree->getChildren();
     $html = '<li>';
     $html .= '<a href="' . $menuTree->getUrl() . '"><span>' . $this->escapeHtml($menuTree->getName()) . '</span></a>';
     $html .= '<div class="drop"><div class="drop-holder"><div class="col-frame"><div class="col-holder">';
     $index = 1;
     foreach ($children as $child) {
         $html .= '<div class="col">';
         $html .= '<strong class="title-drop">' . $this->escapeHtml($child->getName()) . '</strong><ul>';
         $secondLevelChildren = $child->getChildren();
         $childrenCount = $secondLevelChildren->count();
         $key = 0;
         foreach ($secondLevelChildren as $ch) {
             if ($key == 5) {
                 break;
             }
             $html .= '<li><a href="' . $ch->getUrl() . '">' . $this->escapeHtml($ch->getName()) . '</a></li>';
             $key++;
         }
         $html .= '</ul>';
         if ($childrenCount > 5 || $childrenCount == 0) {
             $html .= '<a class="all-links" href="' . $child->getUrl() . '">All ' . $this->escapeHtml($child->getName()) . '</a>';
         }
         $html .= '</div>';
         if ($index % 3 == 0 && $index > 0) {
             $html .= '</div><div class="col-holder">';
         }
         $index++;
     }
     $html .= '</div></div></div></div>';
     $html .= '</li>';
     return $html;
 }
开发者ID:xiaoguizhidao,项目名称:magento,代码行数:38,代码来源:Topmenu.php

示例4: _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

示例5: _getNodeJson

 /**
  * Get JSON of a tree node or an associative array
  *
  * @param Varien_Data_Tree_Node|array $node
  * @param int $level
  * @return string
  */
 protected function _getNodeJson($node, $level = 1)
 {
     $item = array();
     $item['text'] = $this->htmlEscape($node->getName());
     if ($this->_withProductCount) {
         $item['text'] .= ' (' . $node->getProductCount() . ')';
     }
     $item['id'] = $node->getId();
     $item['path'] = $node->getData('path');
     $item['cls'] = 'folder ' . ($node->getIsActive() ? 'active-category' : 'no-active-category');
     $item['allowDrop'] = false;
     $item['allowDrag'] = false;
     if ($node->hasChildren()) {
         $item['children'] = array();
         foreach ($node->getChildren() as $child) {
             $item['children'][] = $this->_getNodeJson($child, $level + 1);
         }
     }
     if (empty($item['children']) && (int) $node->getChildrenCount() > 0) {
         $item['children'] = array();
     }
     if (!empty($item['children'])) {
         $item['expanded'] = true;
     }
     if (in_array($node->getId(), $this->getCategoryIds())) {
         $item['checked'] = true;
     }
     return $item;
 }
开发者ID:CopeX,项目名称:BannerSlider-Magento,代码行数:36,代码来源:Categories.php

示例6: _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

示例7: drawItem

 /**
  * @param Varien_Data_Tree_Node $category
  * @param int $level
  * @param boolean $last
  * @return string
  */
 function drawItem($category, $categoryDepth = 0, $last = false)
 {
     $html = '';
     if (!$category->getIsActive() && !$this->categoryIsRoot($category)) {
         return $html;
     }
     if (!$this->categoryHasProductUnderIt($category)) {
         return;
     }
     $html .= '<li>';
     $html .= '<div class="vaf-cat-toggler">';
     $html .= $this->htmlEscape($this->categoryName($category));
     $html .= '<div class="vaf-toggle-icon vaf-toggle-icon-plus"></div>';
     $html .= '</div>' . "\n";
     $html .= '<div class="vaf-toggle">';
     if ($category->hasChildren()) {
         $htmlChildren = $this->drawCategoryCollection($category, $categoryDepth);
         if (!empty($htmlChildren)) {
             $html .= '<ul >' . "\n" . $htmlChildren . '</ul>';
         }
     }
     $html .= $this->drawProductCollection($category);
     $html .= '</div>';
     $html .= '</li>' . "\n";
     return $html;
 }
开发者ID:hashir-dhattiwala,项目名称:vfmagento,代码行数:32,代码来源:Group.php

示例8: _getHtml

 /**
  * @param Varien_Data_Tree_Node $menuTree
  * @param string                $childrenWrapClass
  *
  * @return string
  */
 protected function _getHtml(Varien_Data_Tree_Node $menuTree, $childrenWrapClass)
 {
     $html = '';
     $counter = 1;
     $children = $menuTree->getChildren();
     $parentLevel = $menuTree->getLevel();
     $childLevel = is_null($parentLevel) ? 0 : $parentLevel + 1;
     $childrenCount = $children->count();
     $parentPositionClass = $menuTree->getPositionClass();
     $itemPositionClassPrefix = $parentPositionClass ? $parentPositionClass . '-' : 'nav-';
     foreach ($children as $child) {
         $child->setLevel($childLevel);
         $child->setIsFirst($counter == 1);
         $child->setIsLast($counter == $childrenCount);
         $child->setPositionClass($itemPositionClassPrefix . $counter);
         $outermostClassCode = '';
         $outermostClass = $menuTree->getOutermostClass();
         if ($childLevel == 0 && $outermostClass) {
             $outermostClassCode = ' class="' . $outermostClass . '" ';
             $child->setClass($outermostClass);
         }
         $blockName = $childLevel == 0 ? 'bennoislost.easy-navigation.renderer.with-children' : 'bennoislost.easy-navigation.renderer.single';
         $html .= $this->_renderBlockItem($blockName, $childrenWrapClass, $child, $outermostClassCode);
         $counter++;
     }
     return $html;
 }
开发者ID:bennoislost,项目名称:easy-navigation,代码行数:33,代码来源:Renderer.php

示例9: BuildBranch

    public function BuildBranch(Varien_Data_Tree_Node $node)
    {
        $buildString = '<li style="padding-left: 16px;">';
        $buildString .= '<div class="tree-level-' . $node->getLevel() . '">';
        if ($node->getChildrenCount() != 0) {
            $buildString .= '<div class="opener" id="opener' . $node->getId() . '"  OnClick="OpenMe(this)"></div>';
        } else {
            $buildString .= '<div class="child"></div>';
        }
        $buildString .= '
			<input type="checkbox" class="inputcb" id="inputcb' . $node->getId() . '" OnClick="Decide(this)" enabled="false"/>
			<div class="folder"></div>
			<a tabindex="1" href="#" hidefocus="on" id="linkItem"><span unselectable="on" id="extdd-' . $node->getLevel() . '">' . $node->getName() . '</a>
		';
        $buildString .= '</div>';
        if ($node->getChildrenCount() != 0) {
            $buildString .= '<ul id="ToOpen' . $node->getId() . '">';
            foreach ($node->getChildren() as $child) {
                $buildString .= $this->BuildBranch($child);
            }
            $buildString .= '</ul>';
        }
        $buildString .= '</li>';
        return $buildString;
    }
开发者ID:rcclaudrey,项目名称:dev,代码行数:25,代码来源:Categories.php

示例10: _isCategoryClickAble

 /**
  * Check if click able enabled for category.
  *
  * @param Varien_Data_Tree_Node|Mage_Catalog_Model_Category $category
  * @return bool
  */
 protected function _isCategoryClickAble($category)
 {
     $isCategoryClickAbleStatus = true;
     $isCategoryClickAble = $category->getData(Monsoon_Test_Helper_Data::IS_CLICK_ABLE_LINK_CODE);
     if ($isCategoryClickAble !== null && (bool) $isCategoryClickAble === false) {
         $isCategoryClickAbleStatus = false;
     }
     return $isCategoryClickAbleStatus;
 }
开发者ID:sergiozt,项目名称:monsoon,代码行数:15,代码来源:Observer.php

示例11: _getHtml

 /**
  * {@inheritDoc}
  */
 protected function _getHtml(Varien_Data_Tree_Node $menuTree, $childrenWrapClass)
 {
     $html = '';
     $children = $menuTree->getChildren();
     $parentLevel = $menuTree->getLevel();
     $childLevel = is_null($parentLevel) ? 0 : $parentLevel + 1;
     $counter = 1;
     $childrenCount = $children->count();
     $parentPositionClass = $menuTree->getPositionClass();
     $itemPositionClassPrefix = $parentPositionClass ? $parentPositionClass . '-' : 'nav-';
     foreach ($children as $child) {
         $child->setLevel($childLevel);
         $child->setIsFirst($counter == 1);
         $child->setIsLast($counter == $childrenCount);
         $child->setPositionClass($itemPositionClassPrefix . $counter);
         $outermostClassCode = '';
         $outermostClass = $menuTree->getOutermostClass();
         if ($childLevel == 0 && $outermostClass) {
             $outermostClassCode = ' class="' . $outermostClass . '" ';
             $child->setClass($outermostClass);
         }
         if ($child->hasChildren()) {
             $outermostClassCode .= ' data-toggle="dropdown" ';
         }
         $html .= '<li ' . $this->_getRenderedMenuItemAttributes($child) . '>';
         $html .= '<a href="' . $child->getUrl() . '" ' . $outermostClassCode . '><span>';
         $html .= $this->escapeHtml($child->getName());
         if ($child->hasChildren()) {
             $html .= ' <b class="caret"></b>';
         }
         $html .= '</span></a>';
         if ($child->hasChildren()) {
             if (!empty($childrenWrapClass)) {
                 $html .= '<div class="' . $childrenWrapClass . '">';
             }
             $html .= '<ul class="level' . $childLevel . ' dropdown-menu">';
             if (Mage::getStoreConfig('catalog/navigation/top_in_dropdown') && $childLevel == 0) {
                 $prefix = Mage::getStoreConfig('catalog/navigation/top_in_dropdown_prefix');
                 $suffix = Mage::getStoreConfig('catalog/navigation/top_in_dropdown_suffix');
                 $html .= '<li class="level1 level-top-in-dropdown">';
                 $html .= '<a href="' . $child->getUrl() . '"><span>';
                 $html .= $this->escapeHtml($this->__($prefix) . ' ' . $child->getName() . ' ' . $suffix);
                 $html .= '</span></a>';
                 $html .= '</li>';
                 $html .= '<li class="divider"></li>';
             }
             $html .= $this->_getHtml($child, $childrenWrapClass);
             $html .= '</ul>';
             if (!empty($childrenWrapClass)) {
                 $html .= '</div>';
             }
         }
         $html .= '</li>';
         $counter++;
     }
     return $html;
 }
开发者ID:a13wes,项目名称:MRKT,代码行数:60,代码来源:Topmenu.php

示例12: add

 /**
  * Adds a node to this node
  */
 public function add(Varien_Data_Tree_Node $node)
 {
     $node->setParent($this->_container);
     // Set the Tree for the node
     if ($this->_container->getTree() instanceof Varien_Data_Tree) {
         $node->setTree($this->_container->getTree());
     }
     $this->_nodes[$node->getId()] = $node;
     return $node;
 }
开发者ID:arslbbt,项目名称:mangentovies,代码行数:13,代码来源:Collection.php

示例13: _exportProductCollection

 /**
  * Export product collection
  *
  * @param Varien_Data_Tree_Node $category
  */
 protected function _exportProductCollection($category)
 {
     $categoryModel = Mage::getModel('catalog/category')->load($category->getId());
     $this->setCategory($categoryModel)->setLayer(Mage::getSingleton('catalog/layer'));
     foreach ($this->_getProductCollection() as $product) {
         $product->load($product->getEntityId());
         Mage::app()->getRequest()->setParam('id', $product->getId());
         $this->_getExportModel(self::TYPE_PRODUCT)->setProduct($product)->exportData();
         $this->_getExportModel(self::TYPE_GALLERY)->setProduct($product)->exportData();
         $this->_getExportModel(self::TYPE_REVIEW)->setProduct($product)->exportData();
     }
 }
开发者ID:okite11,项目名称:frames21,代码行数:17,代码来源:Product.php

示例14: _getHtml

 /**
  * Recursively generates top menu html from data that is specified in $menuTree
  *
  * @param Varien_Data_Tree_Node $menuTree
  * @param string $childrenWrapClass
  * @return string
  */
 protected function _getHtml(Varien_Data_Tree_Node $menuTree, $childrenWrapClass)
 {
     $html = '';
     $children = $menuTree->getChildren();
     $parentLevel = $menuTree->getLevel();
     $childLevel = is_null($parentLevel) ? 0 : $parentLevel + 1;
     $counter = 1;
     $childrenCount = $children->count();
     $parentPositionClass = $menuTree->getPositionClass();
     $itemPositionClassPrefix = $parentPositionClass ? $parentPositionClass . '-' : 'nav-';
     $brandCategoryId = Mage::getStoreConfig('brand/brand/category_id');
     $_helperBrands = Mage::helper('brand');
     $brandUrl = Mage::getUrl($_helperBrands->getBrandsUrl());
     foreach ($children as $child) {
         $child->setLevel($childLevel);
         $child->setIsFirst($counter == 1);
         $child->setIsLast($counter == $childrenCount);
         $child->setPositionClass($itemPositionClassPrefix . $counter);
         $outermostClassCode = '';
         $outermostClass = $menuTree->getOutermostClass();
         if ($childLevel == 0 && $outermostClass) {
             $outermostClassCode = ' class="' . $outermostClass . '" ';
             $child->setClass($outermostClass);
         }
         $html .= '<li ' . $this->_getRenderedMenuItemAttributes($child) . '>';
         $categoryId = str_replace("category-node-", "", $child->getId());
         //$url=($categoryId==$brandCategoryId)?$brandUrl:$child->getUrl();
         $url = $child->getUrl();
         $html .= '<a href="' . $url . '" ' . $outermostClassCode . '><span>' . $this->escapeHtml($child->getName()) . '</span></a>';
         if ($child->hasChildren()) {
             if (!empty($childrenWrapClass)) {
                 $html .= '<div class="' . $childrenWrapClass . '">';
             }
             $html .= '<ul class="level' . $childLevel . '">';
             /*if($childLevel==0)
              	{
                	 $html .= '<div class="submenu">';
              	}*/
             $html .= $this->_getHtml($child, $childrenWrapClass);
             /*if($childLevel==0)
               {
                 $html .= '</div>';
               }*/
             $html .= '</ul>';
             if (!empty($childrenWrapClass)) {
                 $html .= '</div>';
             }
         }
         $html .= '</li>';
         $counter++;
     }
     return $html;
 }
开发者ID:buttasg,项目名称:cowgirlk,代码行数:60,代码来源:Topmenu.php

示例15: _isActiveMenuCategory

 /**
  * Checks whether category belongs to active category's path
  *
  * @param Varien_Data_Tree_Node $category
  * @return bool
  */
 protected function _isActiveMenuCategory($category)
 {
     $catalogLayer = Mage::getSingleton('catalog/layer');
     if (!$catalogLayer) {
         return false;
     }
     $currentCategory = $catalogLayer->getCurrentCategory();
     if (!$currentCategory) {
         return false;
     }
     $categoryPathIds = explode(',', $currentCategory->getPathInStore());
     return in_array($category->getId(), $categoryPathIds);
 }
开发者ID:bennoislost,项目名称:easy-navigation,代码行数:19,代码来源:Add.php


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