本文整理汇总了PHP中Mage_Catalog_Model_Category::getChildrenNodes方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Catalog_Model_Category::getChildrenNodes方法的具体用法?PHP Mage_Catalog_Model_Category::getChildrenNodes怎么用?PHP Mage_Catalog_Model_Category::getChildrenNodes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Catalog_Model_Category
的用法示例。
在下文中一共展示了Mage_Catalog_Model_Category::getChildrenNodes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getChildCategories
/**
* Recursively returns a value / label array of all active categories
* @param Mage_Catalog_Model_Category $category
* @param String $parentname
* @return array
*/
private function getChildCategories($category, $parentname = '')
{
//category not active - skip it
if (!$category->getIsActive()) {
return '';
}
//array containing all the categories to return
$ret = array();
/* Add the current category to return array
* Root categories shouldn't be selected
*/
if ($category->getLevel() > 1) {
$ret[$category->getID()] = $category->getName() . $parentname;
}
// get all children
if (Mage::helper('catalog/category_flat')->isEnabled()) {
$children = (array) $category->getChildrenNodes();
$childrenCount = count($children);
} else {
$children = $category->getChildrenCategories();
$childrenCount = $children->count();
}
$hasChildren = $children && $childrenCount;
// select active children
$activeChildren = array();
foreach ($children as $child) {
if ($child->getIsActive()) {
$activeChildren[] = $child;
}
}
$activeChildrenCount = count($activeChildren);
$hasActiveChildren = $activeChildrenCount > 0;
/**
* Use recursion to include all children categories too
*/
foreach ($activeChildren as $child) {
$childarray = $this->getChildCategories($child, " / " . $category->getName() . $parentname);
foreach ($childarray as $k => $v) {
$ret[$k] = $v;
}
}
return $ret;
}
示例2: drawItemSingle
/**
* Enter description here...
*
* @param Mage_Catalog_Model_Category $category
* @param int $level
* @param boolean $last
* @return string
*/
public function drawItemSingle($category, $level = 0, $last = false)
{
$html = '';
if (!$category->getIsActive()) {
return $html;
}
if (Mage::helper('catalog/category_flat')->isEnabled()) {
$children = $category->getChildrenNodes();
$childrenCount = count($children);
} else {
$children = $category->getChildren();
$childrenCount = $children->count();
}
$hasChildren = $children && $childrenCount;
$html .= '<li';
if ($hasChildren) {
$html .= ' onmouseover="toggleMenu(this,1)" onmouseout="toggleMenu(this,0)"';
}
$html .= ' class="level' . $level;
$html .= ' nav-' . str_replace('/', '-', Mage::helper('catalog/category')->getCategoryUrlPath($category->getRequestPath()));
if ($this->isCategoryActive($category)) {
$html .= ' active';
}
if ($last) {
$html .= ' last';
}
if ($hasChildren) {
$cnt = 0;
foreach ($children as $child) {
if ($child->getIsActive()) {
$cnt++;
}
}
if ($cnt > 0) {
$html .= ' parent';
}
}
$html .= '">' . "\n";
$html .= '<a href="' . $this->getCategoryUrl($category) . '"><span>' . $this->htmlEscape($category->getName()) . '</span></a>' . "\n";
$html .= '</li>' . "\n";
return $html;
}
示例3: _renderCategoryMenuItemHtml
/**
* Render category to html
*
* @param Mage_Catalog_Model_Category $category
* @param int Nesting level number
* @param boolean Whether ot not this item is last, affects list item class
* @param boolean Whether ot not this item is first, affects list item class
* @param boolean Whether ot not this item is outermost, affects list item class
* @param string Extra class of outermost list items
* @param string If specified wraps children list in div with this class
* @param boolean Whether ot not to add on* attributes to list item
* @return string
*/
protected function _renderCategoryMenuItemHtml($category, $level = 0, $isLast = false, $isFirst = false, $isOutermost = false, $outermostItemClass = '', $childrenWrapClass = '', $noEventAttributes = false)
{
if (!$category->getIsActive()) {
return '';
}
$html = array();
// get all children
if (Mage::helper('catalog/category_flat')->isEnabled()) {
$children = (array) $category->getChildrenNodes();
$childrenCount = count($children);
} else {
$children = $category->getChildren();
$childrenCount = $children->count();
}
$hasChildren = $children && $childrenCount;
// select active children
$activeChildren = array();
foreach ($children as $child) {
if ($child->getIsActive()) {
$activeChildren[] = $child;
}
}
$activeChildrenCount = count($activeChildren);
$hasActiveChildren = $activeChildrenCount > 0;
// prepare list item html classes
$classes = array();
$classes[] = 'level' . $level;
$classes[] = 'nav-' . $this->_getItemPosition($level);
if ($this->isCategoryActive($category)) {
$classes[] = 'active';
}
$linkClass = '';
if ($isOutermost && $outermostItemClass) {
$classes[] = $outermostItemClass;
$linkClass = ' class="' . $outermostItemClass . '"';
}
if ($isFirst) {
$classes[] = 'first';
}
if ($isLast) {
$classes[] = 'last';
}
if ($hasActiveChildren) {
$classes[] = 'parent';
}
// prepare list item attributes
$attributes = array();
if (count($classes) > 0) {
$attributes['class'] = implode(' ', $classes);
}
if ($hasActiveChildren && !$noEventAttributes) {
$attributes['onmouseover'] = 'toggleMenu(this,1)';
$attributes['onmouseout'] = 'toggleMenu(this,0)';
}
// assemble list item with attributes
$htmlLi = '<li';
foreach ($attributes as $attrName => $attrValue) {
$htmlLi .= ' ' . $attrName . '="' . str_replace('"', '\\"', $attrValue) . '"';
}
$htmlLi .= '>';
$html[] = $htmlLi;
$html[] = '<a href="' . $this->getCategoryUrl($category) . '"' . $linkClass . '>';
$html[] = '<span>' . $this->escapeHtml($category->getName()) . '</span>';
$html[] = '</a>';
// render children
$htmlChildren = '';
$j = 0;
foreach ($activeChildren as $child) {
$htmlChildren .= $this->_renderCategoryMenuItemHtml($child, $level + 1, $j == $activeChildrenCount - 1, $j == 0, false, $outermostItemClass, $childrenWrapClass, $noEventAttributes);
$j++;
}
if (!empty($htmlChildren)) {
if ($childrenWrapClass) {
$html[] = '<div class="' . $childrenWrapClass . '">';
}
$html[] = '<ul class="level' . $level . '">';
$html[] = $htmlChildren;
$html[] = '</ul>';
if ($childrenWrapClass) {
$html[] = '</div>';
}
}
$html[] = '</li>';
$html = implode("\n", $html);
return $html;
}
示例4: _renderCategoryMenuItemHtml
/**
* Render category to html
*
* @param Mage_Catalog_Model_Category $category
* @param int Nesting level number
* @param boolean Whether ot not this item is last, affects list item class
* @param boolean Whether ot not this item is first, affects list item class
* @param boolean Whether ot not this item is outermost, affects list item class
* @param string Extra class of outermost list items
* @param string If specified wraps children list in div with this class
* @param boolean Whether ot not to add on* attributes to list item
* @return string
*/
protected function _renderCategoryMenuItemHtml($category, $level = 0, $isLast = false, $isFirst = false, $isOutermost = false, $outermostItemClass = '', $childrenWrapClass = '', $noEventAttributes = false)
{
if (!$category->getIsActive()) {
return '';
}
$config = $this->getConfig();
$html = array();
$expanded = null;
$ulThumb = '';
$image = '';
$thumb = '';
$htmlLi = '';
// get all children
if (Mage::helper('catalog/category_flat')->isEnabled()) {
$children = (array) $category->getChildrenNodes();
$childrenCount = count($children);
} else {
$children = $category->getChildren();
if (!$this->_getHelper()->isSearchResultsPage()) {
$childrenCount = $children->count();
} else {
if (is_string($children)) {
$children = explode(',', $children);
}
$childrenCount = count($children);
}
}
// select active children
$activeChildren = array();
foreach ($children as $child) {
if ($child->getIsActive()) {
$activeChildren[] = $child;
}
}
$activeChildrenCount = count($activeChildren);
$hasActiveChildren = $activeChildrenCount > 0;
// prepare list item html classes
$classes = array();
$classes[] = 'level' . $level;
$classes[] = 'nav-' . $this->_getItemPosition($level);
if ($this->isCategoryActive($category)) {
$classes[] = 'active';
} else {
if (Mage::registry('current_product') !== null && $config->activeProductCategoriesInDirectAccess()) {
$classes = $this->_getCategoryModel()->getProductCategoriesInDirectAccess($category, $classes);
}
}
$linkClass = '';
if ($isOutermost && $outermostItemClass) {
$classes[] = $outermostItemClass;
$linkClass = ' class="' . $outermostItemClass . '"';
}
if ($isFirst) {
$classes[] = 'first';
}
if ($isLast) {
$classes[] = 'last';
}
if ($hasActiveChildren) {
$classes[] = 'parent';
}
// prepare list item attributes
$attributes = array();
if (count($classes) > 0) {
$attributes['class'] = implode(' ', $classes);
}
if ($hasActiveChildren && !$noEventAttributes) {
$attributes['onmouseover'] = 'toggleMenu(this,1)';
$attributes['onmouseout'] = 'toggleMenu(this,0)';
}
// assemble list item with attributes
$thumbWidth = 14;
$thumbHeight = 14;
$thumbPosition = $config->getThumbPosition();
$liMarginLeft = 0;
$ulMarginLeft = 5;
$ulPaddingLeft = 10;
// define image thumbnail variables
if ($config->isThumbImageActive()) {
if ($config->getThumbSize()) {
$thumbWidth = $config->getThumbWidth();
$thumbHeight = $config->getThumbHeight();
}
$thumbnail = $this->_getCategoryModel()->load($category->getId())->getThumbnailImageUrl();
$ulThumb = ' ul-thumb';
if (!empty($thumbnail)) {
$image = '<img class="thumb-img-' . $thumbPosition . '" src="' . $thumbnail . '" style= "width:' . $thumbWidth . 'px; height:' . $thumbHeight . 'px; float: ' . $thumbPosition . ';" />';
//.........这里部分代码省略.........
示例5: drawItem2
/**
* Enter description here...
*
* @param Mage_Catalog_Model_Category $category
* @param int $level
* @param boolean $last
* @return string
*/
public function drawItem2($category, $level = 0, $last = false)
{
$html = '';
if (!$category->getIsActive()) {
return $html;
}
if (Mage::helper('catalog/category_flat')->isEnabled()) {
$children = $category->getChildrenNodes();
$childrenCount = count($children);
} else {
$children = $category->getChildren();
$childrenCount = $children->count();
}
$hasChildren = $children && $childrenCount;
$html .= '<li><a href="' . $this->getCategoryUrl($category) . '">' . $this->htmlEscape($category->getName()) . '</a>' . '</li>' . "\n";
return $html;
}
示例6: _renderCategoryMenuItemHtml
/**
* Render category to html
*
* @param Mage_Catalog_Model_Category $category
* @param int Nesting level number
* @param boolean Whether ot not this item is last, affects list item class
* @param boolean Whether ot not this item is first, affects list item class
* @param boolean Whether ot not this item is outermost, affects list item class
* @param string Extra class of outermost list items
* @param string If specified wraps children list in div with this class
* @param boolean Whether ot not to add on* attributes to list item
* @return string
*/
protected function _renderCategoryMenuItemHtml($category, $level = 0, $isLast = false, $isFirst = false, $isOutermost = false, $outermostItemClass = '', $childrenWrapClass = '', $noEventAttributes = false)
{
if (!$category->getIsActive()) {
return '';
}
$category_ids = array();
$postData = Mage::app()->getRequest()->getPost('filter_cat');
foreach ($postData as $posdata) {
array_push($category_ids, $posdata);
}
$config = $this->getConfig();
$html = array();
$expanded = null;
$ulThumb = '';
$image = '';
$thumb = '';
$htmlLi = '';
// get all children
if (Mage::helper('catalog/category_flat')->isEnabled()) {
$children = (array) $category->getChildrenNodes();
$childrenCount = count($children);
} else {
$children = $category->getChildren();
if (!$this->_getHelper()->isSearchResultsPage()) {
$childrenCount = $children->count();
} else {
if (is_string($children)) {
$children = explode(',', $children);
}
$childrenCount = count($children);
}
}
// select active children
$activeChildren = array();
foreach ($children as $child) {
if ($child->getIsActive()) {
$activeChildren[] = $child;
}
}
$activeChildrenCount = count($activeChildren);
$hasActiveChildren = $activeChildrenCount > 0;
// prepare list item html classes
$classes = array();
$classes[] = 'level' . $level;
$classes[] = 'nav-' . $this->_getItemPosition($level);
if ($this->isCategoryActive($category)) {
$classes[] = 'active';
} else {
if (Mage::registry('current_product') !== null && $config->activeProductCategoriesInDirectAccess()) {
$classes = $this->_getCategoryModel()->getProductCategoriesInDirectAccess($category, $classes);
}
}
$linkClass = '';
if ($isOutermost && $outermostItemClass) {
$classes[] = $outermostItemClass;
$linkClass = ' class="' . $outermostItemClass . '"';
}
if ($isFirst) {
$classes[] = 'first';
}
if ($isLast) {
$classes[] = 'last';
}
if ($hasActiveChildren) {
$classes[] = 'parent has-sub';
}
// prepare list item attributes
$attributes = array();
if (count($classes) > 0) {
$attributes['class'] = implode(' ', $classes);
}
if ($hasActiveChildren && !$noEventAttributes) {
$attributes['onmouseover'] = 'toggleMenu(this,1)';
$attributes['onmouseout'] = 'toggleMenu(this,0)';
}
// assemble list item with attributes
$thumbWidth = 14;
$thumbHeight = 14;
$thumbPosition = $config->getThumbPosition();
$liMarginLeft = 0;
$ulMarginLeft = 5;
$ulPaddingLeft = 10;
// define image thumbnail variables
if ($config->isThumbImageActive()) {
if ($config->getThumbSize()) {
$thumbWidth = $config->getThumbWidth();
$thumbHeight = $config->getThumbHeight();
//.........这里部分代码省略.........
示例7: drawItem
/**
* Enter description here...
*
* @param Mage_Catalog_Model_Category $category
* @param int $level
* @param boolean $last
* @return string
*/
public function drawItem($category, $level = 0, $last = false)
{
$html = '';
if (!$category->getIsActive()) {
return $html;
}
if (Mage::helper('catalog/category_flat')->isEnabled()) {
$children = $category->getChildrenNodes();
$childrenCount = count($children);
} else {
$children = $category->getChildren();
$childrenCount = $children->count();
}
$hasChildren = $children && $childrenCount;
$html .= '<li';
if ($hasChildren) {
//$html.= ' onmouseover="Element.addClassName(this, \'over\') " onmouseout="Element.removeClassName(this, \'over\') "';
}
$html .= ' class="level' . $level;
$html .= ' nav-' . str_replace('/', '-', Mage::helper('catalog/category')->getCategoryUrlPath($category->getRequestPath()));
if ($this->isCategoryActive($category)) {
$html .= ' active';
}
if ($last) {
$html .= ' last';
}
if ($hasChildren) {
$cnt = 0;
foreach ($children as $child) {
if ($child->getIsActive()) {
$cnt++;
}
}
if ($cnt > 0) {
$html .= ' parent';
}
}
$html .= '">' . "\n";
if ($level == 0) {
$html .= '<a href="' . $this->getCategoryUrl($category) . '"><span>' . $this->htmlEscape($category->getName()) . '</span></a><span class="head"><a href="#" style="float:right;"></a></span>' . "\n";
} else {
$html .= '<a href="' . $this->getCategoryUrl($category) . '"><span>' . $this->htmlEscape($category->getName()) . '</span></a>' . "\n";
}
if ($hasChildren) {
$j = 0;
$htmlChildren = '';
foreach ($children as $child) {
if ($child->getIsActive()) {
$htmlChildren .= $this->drawItem($child, $level + 1, ++$j >= $cnt);
}
}
if (!empty($htmlChildren)) {
$html .= '<ul class="level' . $level . '">' . "\n" . $htmlChildren . '</ul>';
}
}
$html .= '</li>' . "\n";
return $html;
}
示例8: _renderCategoryMenuItemHtml
/**
* Render category to html
*
* @param Mage_Catalog_Model_Category $category
* @param int Nesting level number
* @param boolean Whether ot not this item is last, affects list item class
* @param boolean Whether ot not this item is first, affects list item class
* @param boolean Whether ot not this item is outermost, affects list item class
* @param string Extra class of outermost list items
* @param string If specified wraps children list in div with this class
* @param boolean Whether ot not to add on* attributes to list item
* @return string
*/
protected function _renderCategoryMenuItemHtml($category, $level = 0, $isLast = false, $isFirst = false, $isOutermost = false, $outermostItemClass = '', $childrenWrapClass = '', $noEventAttributes = false)
{
$level2 = $level + 1;
if (!$category->getIsActive()) {
return '';
}
$html = array();
$childrenWrapClass = true;
// get all children
if (Mage::helper('catalog/category_flat')->isEnabled()) {
$children = (array) $category->getChildrenNodes();
$childrenCount = count($children);
} else {
$children = $category->getChildren();
$childrenCount = $children->count();
}
$hasChildren = $children && $childrenCount;
// select active children
$activeChildren = array();
foreach ($children as $child) {
if ($child->getIsActive()) {
$activeChildren[] = $child;
}
}
$activeChildrenCount = count($activeChildren);
$hasActiveChildren = $activeChildrenCount > 0;
// prepare list item html classes
$classes = array();
$classes[] = 'level' . $level;
$test = 'nav-' . $this->_getItemPosition($level);
$classes[] = $test;
if ($this->isCategoryActive($category)) {
$classes[] = 'active';
}
$linkClass = '';
if ($isOutermost && $outermostItemClass) {
$classes[] = $outermostItemClass;
$linkClass = ' class="' . $outermostItemClass . '"';
}
if ($isFirst) {
if ($level == 0) {
$html[] = '<li class="first-home"><a href="/"><span class="navigation-name">' . $this->__('Home') . '</span></a></li>';
}
$classes[] = 'first';
}
if ($isLast) {
$classes[] = 'last';
}
if ($hasActiveChildren) {
$classes[] = 'parent';
}
// prepare list item attributes
$attributes = array();
if (count($classes) > 0) {
$attributes['class'] = implode(' ', $classes);
}
if ($hasActiveChildren && !$noEventAttributes) {
$attributes['onmouseover'] = 'toggleMenu(this,1)';
$attributes['onmouseout'] = 'toggleMenu(this,0)';
}
// assemble list item with attributes
$htmlLi = '<li';
foreach ($attributes as $attrName => $attrValue) {
$htmlLi .= ' ' . $attrName . '="' . str_replace('"', '\\"', $attrValue) . '"';
}
$htmlLi .= '>';
$html[] = $htmlLi;
$html[] = '<a href="' . $this->getCategoryUrl($category) . '"' . $linkClass . '>';
$html[] = '<span class="navigation-name">' . $this->escapeHtml($category->getName()) . '</span>';
if ($hasActiveChildren && $level == 0 && !in_array('last', $classes)) {
$html[] = '<span class="arrow"> </span>';
}
$html[] = '</a>';
// render children
$htmlChildren = '';
$j = 0;
foreach ($activeChildren as $child) {
$htmlChildren .= $this->_renderCategoryMenuItemHtml($child, $level + 1, $j == $activeChildrenCount - 1, $j == 0, false, $outermostItemClass, $childrenWrapClass, $noEventAttributes);
$j++;
}
if (!empty($htmlChildren)) {
if ($childrenWrapClass) {
$categorytmp = Mage::getModel('catalog/category')->load($category->getId());
$html[] = '<div class="dropdown_5columns_' . $test . '"><span class="top"></span><span class="category-title">' . $categorytmp->getCategorySpecName() . '</span>';
}
$htmlChildren .= '<li class="level' . ($level + 1) . ' view-all"><a href="' . $this->getCategoryUrl($category) . '?viewall=1">+ View All</a></li>';
$html[] = '<ul class="level' . $level . '">';
//.........这里部分代码省略.........
示例9: _renderCategoryMenuItemHtml
/**
* Render category to html
*
* @param Mage_Catalog_Model_Category $category
* @param int Nesting level number
* @param boolean Whether ot not this item is last, affects list item class
* @param boolean Whether ot not this item is first, affects list item class
* @param boolean Whether ot not this item is outermost, affects list item class
* @param string Extra class of outermost list items
* @param string If specified wraps children list in div with this class
* @param boolean Whether ot not to add on* attributes to list item
* @return string
*/
public function _renderCategoryMenuItemHtml($category, $level = 0, $isLast = false, $isFirst = false, $isOutermost = false, $outermostItemClass = '', $childrenWrapClass = '', $noEventAttributes = false)
{
if (!$category->getIsActive()) {
return '';
}
$html = array();
// get all children
if (Mage::helper('catalog/category_flat')->isEnabled()) {
$children = (array) $category->getChildrenNodes();
$childrenCount = count($children);
} else {
$children = $category->getChildren();
$childrenCount = $children->count();
}
$hasChildren = $children && $childrenCount;
// select active children
$activeChildren = array();
foreach ($children as $child) {
if ($child->getIsActive()) {
$activeChildren[] = $child;
}
}
$activeChildrenCount = count($activeChildren);
$hasActiveChildren = $activeChildrenCount > 0;
// prepare list item html classes
$classes = array();
if ($level == 0) {
$classes[] = 'title';
}
$classes[] = 'level' . $level;
$classes[] = 'nav-' . $this->_getItemPosition($level);
if ($this->isCategoryActive($category)) {
$classes[] = 'active';
}
$linkClass = '';
if ($isOutermost && $outermostItemClass) {
$classes[] = $outermostItemClass;
$linkClass = ' class="' . $outermostItemClass . '"';
}
if ($isFirst) {
$classes[] = 'first';
}
if ($isLast) {
$classes[] = 'last';
}
if ($hasActiveChildren) {
$classes[] = 'parent';
}
if ($this->isCategoryActive($category)) {
$classes[] = 'current';
}
$classes[] = 'collapse closed';
// prepare list item attributes
$attributes = array();
if (count($classes) > 0) {
$attributes['class'] = implode(' ', $classes);
}
if ($hasActiveChildren && !$noEventAttributes) {
$attributes['onmouseover'] = 'toggleMenu(this,1)';
$attributes['onmouseout'] = 'toggleMenu(this,0)';
}
if ($level == 0) {
$category_data = Mage::getModel('catalog/category')->load($category->getId());
}
if ($level == 0) {
$html[] = '<li class="col"><ul>';
}
// assemble list item with attributes
$htmlLi = '<li';
foreach ($attributes as $attrName => $attrValue) {
$htmlLi .= ' ' . $attrName . '="' . str_replace('"', '\\"', $attrValue) . '"';
}
$htmlLi .= '>';
$html[] = $htmlLi;
if ($level == 0) {
if ($category_icon = $category_data->getBs_category_icon()) {
$html[] = '<img class="icon" alt="" width="28" src="' . Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . 'wysiwyg/ev_category_icons/' . $category_icon . '">';
}
}
$html[] = '<a class="collapse closed" href="' . $this->getCategoryUrl($category) . '">' . $this->escapeHtml($category->getName());
if ($level == 0) {
$label = $category_data->getBs_category_lable();
if (!empty($label)) {
$html[] = '<span class="hot"> ' . $label . ' </span>';
}
}
$html[] = '</a>';
//.........这里部分代码省略.........
示例10: _renderCategoryMenuItemHtml
/**
* Render category to html
*
* @param Mage_Catalog_Model_Category $category
* @param int Nesting level number
* @param boolean Whether ot not this item is last, affects list item class
* @param boolean Whether ot not this item is first, affects list item class
* @param boolean Whether ot not this item is outermost, affects list item class
* @param string Extra class of outermost list items
* @param string If specified wraps children list in div with this class
* @param boolean Whether ot not to add on* attributes to list item
* @return string
*/
protected function _renderCategoryMenuItemHtml($category, $level = 0, $isLast = false, $isFirst = false, $isOutermost = false, $outermostItemClass = '', $childrenWrapClass = '', $noEventAttributes = false)
{
if (!$category->getIsActive()) {
return '';
}
$html = array();
$js = null;
$expanded = null;
$ulThumb = '';
$image = '';
$thumb = '';
$htmlLi = '';
// get all children
if (Mage::helper('catalog/category_flat')->isEnabled()) {
$children = (array) $category->getChildrenNodes();
$childrenCount = count($children);
} else {
$children = $category->getChildren();
$childrenCount = $children->count();
}
$hasChildren = $children && $childrenCount;
// select active children
$activeChildren = array();
foreach ($children as $child) {
if ($child->getIsActive()) {
$activeChildren[] = $child;
}
}
$activeChildrenCount = count($activeChildren);
$hasActiveChildren = $activeChildrenCount > 0;
// prepare list item html classes
$classes = array();
$classes[] = 'level' . $level;
$classes[] = 'nav-' . $this->_getItemPosition($level);
if ($this->isCategoryActive($category)) {
$classes[] = 'active';
}
$linkClass = '';
if ($isOutermost && $outermostItemClass) {
$classes[] = $outermostItemClass;
$linkClass = ' class="' . $outermostItemClass . '"';
}
if ($isFirst) {
$classes[] = 'first';
}
if ($isLast) {
$classes[] = 'last';
}
if ($hasActiveChildren) {
$classes[] = 'parent';
}
// prepare list item attributes
$attributes = array();
if (count($classes) > 0) {
$attributes['class'] = implode(' ', $classes);
}
if ($hasActiveChildren && !$noEventAttributes) {
$attributes['onmouseover'] = 'toggleMenu(this,1)';
$attributes['onmouseout'] = 'toggleMenu(this,0)';
}
// assemble list item with attributes
$config = Mage::getModel('sidenav/config');
$thumbWidth = 14;
$thumbHeight = 14;
$liMarginLeft = 0;
$ulMarginLeft = 5;
$ulPaddingLeft = 10;
// define image thumbnail variables
if ($config->getThumbImageActive()) {
if ($config->getThumbSize()) {
$thumbWidth = $config->getThumbWidth();
$thumbHeight = $config->getThumbHeight();
}
$thumbnail = $config->load($category->getId())->getThumbnailImageUrl();
$ulThumb = ' ul-thumb';
if (!empty($thumbnail)) {
$image = '<img src="' . $thumbnail . '" style= "width:' . $thumbWidth . 'px; height:' . $thumbHeight . 'px; float: left;" />';
$thumb = ' thumb';
if ($config->getCollapsible() && $config->getThumbImageActive()) {
$liMarginLeft = $thumbWidth + 3;
$ulMarginLeft = 0;
} else {
$liMarginLeft = 0;
$ulMarginLeft = $thumbWidth + 3;
}
$ulPaddingLeft = 0;
} else {
//.........这里部分代码省略.........
示例11: drawItem
/**
* Enter description here...
*
* @param Mage_Catalog_Model_Category $category
* @param int $level
* @param boolean $last
* @return string
*/
public function drawItem($category, $level = 0, $last = false)
{
$html = '';
if (!$category->getIsActive()) {
return $html;
}
if (Mage::helper('catalog/category_flat')->isEnabled()) {
$children = $category->getChildrenNodes();
$childrenCount = count($children);
} else {
$children = $category->getChildren();
$childrenCount = $children->count();
}
$hasChildren = $children && $childrenCount;
$html .= '<li';
if ($hasChildren || $category->getName() == 'Frames') {
$html .= ' onmouseover="toggleMenu(this,1)" onmouseout="toggleMenu(this,0)"';
}
$html .= ' class="level' . $level;
//$html.= ' nav-'.str_replace('/', '-', Mage::helper('catalog/category')->getCategoryUrlPath($category->getRequestPath()));
$html .= ' nav-' . $this->_getItemPosition($level);
if ($this->isCategoryActive($category)) {
$html .= ' active';
}
if ($last) {
$html .= ' last';
}
if ($hasChildren) {
$cnt = 0;
foreach ($children as $child) {
if ($child->getIsActive()) {
$cnt++;
}
}
if ($cnt > 0) {
$html .= ' parent';
}
}
$html .= '">' . "\n";
$html .= '<a href="' . $this->getCategoryUrl($category) . '"><span>' . $this->htmlEscape($category->getName()) . '</span></a>' . "\n";
if ($category->getName() != 'Frames') {
if ($hasChildren) {
$j = 0;
$htmlChildren = '';
foreach ($children as $child) {
if ($child->getIsActive()) {
$htmlChildren .= $this->drawItem($child, $level + 1, ++$j >= $cnt);
}
}
if (!empty($htmlChildren)) {
$html .= '<ul class="level' . $level . '">' . "\n" . $htmlChildren . '</ul>';
}
}
} else {
$_myStore = Mage::app()->getStore()->getCode();
if ($_myStore == 'wholesaledefault') {
$html .= '<ul class="level0">
<li class="level1 nav-1-1">
<a href="' . $this->getBaseURL() . 'frames/mixte-72.html"><span>Mixte</span></a>
</li>
<li class="level1 nav-1-2">
<a href="' . $this->getBaseURL() . 'frames/polyvalent-55.html"><span>Polyvalent</span></a>
</li>
<li class="level1 nav-1-3 last">
<a href="' . $this->getBaseURL() . 'frames/rando-74.html"><span>Rando</span></a>
</li>
</ul>';
} else {
$html .= '<ul class="level0">
<li class="level1 nav-1-1">
<a href="' . $this->getBaseURL() . 'frames/mixte-72.html"><span>Mixte</span></a>
</li>
<li class="level1 nav-1-2">
<a href="' . $this->getBaseURL() . 'frames/polyvalent-55.html"><span>Polyvalent</span></a>
</li>
<li class="level1 nav-1-3">
<a href="' . $this->getBaseURL() . 'frames/rando-74.html"><span>Rando</span></a>
</li>
<li class="level1 nav-1-4 last">
<a href="' . $this->getBaseURL() . 'frames/build-kit.html"><span>Build Kits</span></a>
</li>
</ul>';
}
}
//.........这里部分代码省略.........
示例12: ___renderCategoryMenuItemHtml
/**
* Render category to html
*
* @param Mage_Catalog_Model_Category $category
* @param int Nesting level number
* @param boolean Whether ot not this item is last, affects list item class
* @param boolean Whether ot not this item is first, affects list item class
* @param string Extra class of outermost list items
* @param string If specified wraps children list in div with this class
* @param boolean Whether ot not to add on* attributes to list item
* @return string
*/
protected function ___renderCategoryMenuItemHtml($category, $level = 0, $isLast = false, $isFirst = false, $isOutermost = false, $outermostItemClass = '', $childrenWrapClass = '', $noEventAttributes = false)
{
if (!$category->getIsActive()) {
return '';
}
$html = array();
// get all children
// If Flat Data enabled then use it but only on frontend
$flatHelper = Mage::helper('catalog/category_flat');
if ($flatHelper->isAvailable() && $flatHelper->isBuilt(true) && !Mage::app()->getStore()->isAdmin()) {
$children = (array) $category->getChildrenNodes();
$childrenCount = count($children);
} else {
$children = $category->getChildren();
$childrenCount = $children->count();
}
$hasChildren = $children && $childrenCount;
// select active children
$activeChildren = array();
foreach ($children as $child) {
if ($child->getIsActive()) {
$activeChildren[] = $child;
}
}
$_tmp_children = array();
foreach ($activeChildren as $child) {
if ($child->getIsActive()) {
$_tmp_children[$child->getName()] = $child;
}
}
ksort($_tmp_children, SORT_STRING);
$activeChildren = $_tmp_children;
$activeChildrenCount = count($activeChildren);
$hasActiveChildren = $activeChildrenCount > 0;
// prepare list item html classes
$classes = array();
$classes[] = 'level' . $level;
$classes[] = 'nav-' . $this->_getItemPosition($level);
if ($this->isCategoryActive($category)) {
$classes[] = 'active';
}
$linkClass = '';
if ($isOutermost && $outermostItemClass) {
$classes[] = $outermostItemClass;
$linkClass = ' class="' . $outermostItemClass . '"';
}
if ($isFirst) {
$classes[] = 'first';
}
if ($isLast) {
$classes[] = 'last';
}
if ($hasActiveChildren) {
$classes[] = 'parent';
}
// prepare list item attributes
$attributes = array();
if (count($classes) > 0) {
$attributes['class'] = implode(' ', $classes);
}
if ($hasActiveChildren && !$noEventAttributes) {
$attributes['onmouseover'] = 'toggleMenu(this,1)';
$attributes['onmouseout'] = 'toggleMenu(this,0)';
}
// assemble list item with attributes
$htmlLi = '<li';
foreach ($attributes as $attrName => $attrValue) {
$htmlLi .= ' ' . $attrName . '="' . str_replace('"', '\\"', $attrValue) . '"';
}
$htmlLi .= '>';
$html[] = $htmlLi;
$html[] = '<a href="' . $this->getCategoryUrl($category) . '"' . $linkClass . '>';
$html[] = '<span>' . $this->escapeHtml($category->getName()) . '</span>';
$html[] = '</a>';
// render children
$j = 0;
if (count($activeChildren) > 0) {
$int = 0;
$catCount = count($activeChildren);
$thirdCount = ceil($catCount / 3);
$remain = $catCount % 3;
$colCount = 0;
$htmlChildren = '<ol thirdCount="' . $thirdCount . '" subCats="' . count($activeChildren) . '">';
} else {
$htmlChildren = '';
}
$htmlChildren = '<ol thirdCount="' . $thirdCount . '" subCats="' . count($activeChildren) . '">';
foreach ($activeChildren as $child) {
//.........这里部分代码省略.........
示例13: _renderCategoryMenuItemHtml
/**
* Render category to html
*
* @param Mage_Catalog_Model_Category $category
* @param int Nesting level number
* @param boolean Whether ot not this item is last, affects list item class
* @param boolean Whether ot not this item is first, affects list item class
* @param boolean Whether ot not this item is outermost, affects list item class
* @param string Extra class of outermost list items
* @param string If specified wraps children list in div with this class
* @param boolean Whether ot not to add on* attributes to list item
* @return string
*/
protected function _renderCategoryMenuItemHtml($category, $level = 0, $isLast = false, $isFirst = false, $isOutermost = false, $outermostItemClass = '', $childrenWrapClass = '', $noEventAttributes = false, $showThumbnails = false, $isMobile = false)
{
$_config = Mage::getStoreConfig('milanoconfig/menuoptions');
$ca = Mage::getModel('catalog/category')->load($category->getId());
$categoryMmenuStyle = $ca->getCategoryMmenuStyle();
if (!empty($categoryMmenuStyle)) {
$_config['mmenu_style'] = $categoryMmenuStyle;
}
if (!$category->getIsActive()) {
return '';
}
$html = array();
// check if thumbnail is allowed
if (!$isMobile && $showThumbnails && ($categoryThumbnail = $ca->getThumbnail())) {
$_isThumbnail = true;
}
// get all children
if (Mage::helper('catalog/category_flat')->isEnabled()) {
$children = (array) $category->getChildrenNodes();
$childrenCount = count($children);
} else {
$children = $category->getChildren();
$childrenCount = $children->count();
}
$hasChildren = $children && $childrenCount;
// select active children
$activeChildren = array();
foreach ($children as $child) {
if ($child->getIsActive()) {
$activeChildren[] = $child;
}
}
$activeChildrenCount = count($activeChildren);
$hasActiveChildren = $activeChildrenCount > 0;
// prepare list item html classes
$classes = array();
$classes[] = 'level' . $level;
$classes[] = 'nav-' . $this->_getItemPosition($level);
if ($this->isCategoryActive($category)) {
$classes[] = 'active';
}
$linkClass = '';
$categoryClass = Mage::getModel('catalog/category')->load($category->getId());
// added by Romars
$csscatClass = $categoryClass->getData('navigation_style');
// added by Romars
if ($isOutermost && $outermostItemClass) {
$classes[] = $outermostItemClass;
$linkClass = ' class="' . $outermostItemClass . ' ' . $csscatClass . '"';
// added by Romars
}
if ($isFirst) {
$classes[] = 'first ' . $csscatClass;
// added by Romars
}
if ($isLast) {
$classes[] = 'last ' . $csscatClass;
// added by Romars
}
if ($hasActiveChildren) {
$classes[] = 'parent ' . $csscatClass;
// added by Romars
$this->_columnsCount++;
}
if ($_isThumbnail) {
$classes[] = 'category-thumbnail ' . $csscatClass;
// added by Romars
}
// prepare list item attributes
$attributes = array();
if (count($classes) > 0) {
$attributes['class'] = implode(' ', $classes);
}
if ($hasActiveChildren && !$noEventAttributes) {
$attributes['onmouseover'] = 'toggleMenu(this,1)';
$attributes['onmouseout'] = 'toggleMenu(this,0)';
}
// assemble list item with attributes
$htmlLi = '<li';
foreach ($attributes as $attrName => $attrValue) {
$htmlLi .= ' ' . $attrName . '="' . str_replace('"', '\\"', $attrValue) . '"';
}
$htmlLi .= '>';
$html[] = $htmlLi;
$html[] = '<a href="' . $this->getCategoryUrl($category) . '"' . $linkClass . '>';
// add the thumbnail
if ($_isThumbnail) {
//.........这里部分代码省略.........
示例14: _renderCategoryMenuItemHtml
/**
* Render category to html
*
* @param Mage_Catalog_Model_Category $category
* @param int Nesting level number
* @param boolean Whether ot not this item is last, affects list item class
* @param boolean Whether ot not this item is first, affects list item class
* @param boolean Whether ot not this item is outermost, affects list item class
* @param string Extra class of outermost list items
* @param string If specified wraps children list in div with this class
* @param boolean Whether ot not to add on* attributes to list item
* @return string
*/
protected function _renderCategoryMenuItemHtml($category, $level = 0, $isLast = false, $isFirst = false, $isOutermost = false, $outermostItemClass = '', $childrenWrapClass = '', $noEventAttributes = false)
{
if (!$category->getIsActive()) {
return '';
}
$html = array();
// get all children
if (Mage::helper('catalog/category_flat')->isEnabled()) {
$children = (array) $category->getChildrenNodes();
$childrenCount = count($children);
} else {
$children = $category->getChildren();
$childrenCount = $children->count();
}
$hasChildren = $children && $childrenCount;
// select active children
$activeChildren = array();
foreach ($children as $child) {
if ($child->getIsActive()) {
$activeChildren[] = $child;
}
}
$activeChildrenCount = count($activeChildren);
$hasActiveChildren = $activeChildrenCount > 0;
// prepare list item html classes
$classes = array();
$classes[] = 'level' . $level;
$classes[] = 'nav-' . $this->_getItemPosition($level);
if ($this->isCategoryActive($category)) {
$classes[] = 'active';
}
$linkClass = '';
if ($isOutermost && $outermostItemClass) {
$classes[] = $outermostItemClass;
$linkClass = ' class="' . $outermostItemClass . '"';
}
if ($isFirst) {
$classes[] = 'first';
}
if ($isLast) {
$classes[] = 'last';
}
if ($hasActiveChildren) {
$classes[] = 'parent';
}
// prepare list item attributes
$attributes = array();
if (count($classes) > 0) {
$attributes['class'] = implode(' ', $classes);
}
if ($hasActiveChildren && !$noEventAttributes) {
$attributes['onmouseover'] = 'toggleMenu(this,1)';
$attributes['onmouseout'] = 'toggleMenu(this,0)';
}
// assemble list item with attributes
$htmlLi = '<li';
foreach ($attributes as $attrName => $attrValue) {
$htmlLi .= ' ' . $attrName . '="' . str_replace('"', '\\"', $attrValue) . '"';
}
$htmlLi .= '>';
$html[] = $htmlLi;
$html[] = '<a href="' . $this->getCategoryUrl($category) . '"' . $linkClass . '>';
$html[] = '<span>' . $this->escapeHtml($category->getName()) . '</span>';
$html[] = '</a>';
// render children
$htmlChildren = '';
$j = 0;
$sub_categories = Mage::getModel('catalog/category')->load($category->getEntityId())->getChildrenCategories();
$ctr = 1;
$htmlChildren .= '<span class="groupArrow">';
foreach ($sub_categories as $child) {
$htmlChildren .= '<li>';
$htmlChildren .= '<a href="' . $this->getCategoryUrl($child) . '" >';
$htmlChildren .= '<span>' . $this->escapeHtml($child->getName()) . '</span>';
$htmlChildren .= '</a>';
$htmlChildren .= '</li>';
if ($ctr % 7 == 0) {
echo $ctr . "<br>";
$htmlChildren .= '</span>';
$htmlChildren .= '<span class="groupArrow">';
}
$ctr++;
}
/* $htmlChildren.= '<li>';
$htmlChildren.= '<a href="'.$this->getBaseUrl().'arrivals/?id='.urlencode($category->getEntityId()).'" >';
$htmlChildren.= '<span>New Arrivals</span>';
$htmlChildren.= '</a>';
//.........这里部分代码省略.........
示例15: _renderAthleteCategoryMenuItemHtml
/**
* Render category to html
*
* @param Mage_Catalog_Model_Category $category
* @param int Nesting level number
* @param boolean Whether ot not this item is last, affects list item class
* @param boolean Whether ot not this item is first, affects list item class
* @param boolean Whether ot not this item is outermost, affects list item class
* @param string Extra class of outermost list items
* @param string If specified wraps children list in div with this class
* @param boolean Whether ot not to add on* attributes to list item
* @return string
*/
protected function _renderAthleteCategoryMenuItemHtml($category, $level = 0, $isLast = false, $isFirst = false, $isOutermost = false, $outermostItemClass = '', $childrenWrapClass = '', $noEventAttributes = false)
{
if (!$category->getIsActive()) {
return '';
}
$html = array();
// get all children
if (Mage::helper('catalog/category_flat')->isEnabled()) {
$children = (array) $category->getChildrenNodes();
$childrenCount = count($children);
} else {
$children = $category->getChildren();
$childrenCount = $children->count();
}
$hasChildren = $children && $childrenCount;
// select active children
$activeChildren = array();
foreach ($children as $child) {
if ($child->getIsActive()) {
$activeChildren[] = $child;
}
}
$activeChildrenCount = count($activeChildren);
$hasActiveChildren = $activeChildrenCount > 0;
// prepare list item html classes
$classes = array();
$classes[] = 'level' . $level;
$classes[] = 'nav-' . $this->_getItemPosition($level);
if ($this->isCategoryActive($category)) {
$classes[] = 'active';
}
$linkClass = '';
if ($isOutermost && $outermostItemClass) {
$classes[] = $outermostItemClass;
$linkClass = ' class="' . $outermostItemClass . '"';
}
if ($isFirst) {
$classes[] = 'first';
}
if ($isLast) {
$classes[] = 'last';
}
if ($hasActiveChildren) {
$classes[] = 'parent';
}
// prepare list item attributes
$attributes = array();
if (count($classes) > 0) {
$attributes['class'] = implode(' ', $classes);
}
if ($hasActiveChildren && !$noEventAttributes) {
$attributes['onmouseover'] = 'toggleMenu(this,1)';
$attributes['onmouseout'] = 'toggleMenu(this,0)';
}
// assemble list item with attributes
$htmlLi = '<li';
foreach ($attributes as $attrName => $attrValue) {
$htmlLi .= ' ' . $attrName . '="' . str_replace('"', '\\"', $attrValue) . '"';
}
$htmlLi .= '>';
$html[] = $htmlLi;
$html[] = '<a href="' . $this->getCategoryUrl($category) . '"' . $linkClass . '>';
$html[] = '<span>' . $this->escapeHtml($category->getName()) . '</span>';
$html[] = '</a>';
if ($level == 0) {
//get category description
$ca = Mage::getModel('catalog/category')->load($category->getId());
$description = $ca->getDescription();
if (empty($description) || !Mage::helper('athlete')->getCfg('header/show_description')) {
$columns = 4;
} else {
$columns = 2;
}
$columnItemsNum = array_fill(0, $columns, floor($activeChildrenCount / $columns));
if ($activeChildrenCount % $columns > 0) {
for ($i = 0; $i < $activeChildrenCount % $columns; $i++) {
$columnItemsNum[$i]++;
}
}
$this->_columnHtml = array();
}
// render children
$htmlChildren = '';
$j = 0;
//child index
$i = 0;
//column index
//.........这里部分代码省略.........