本文整理汇总了PHP中Mage_Catalog_Model_Category::getChildren方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Catalog_Model_Category::getChildren方法的具体用法?PHP Mage_Catalog_Model_Category::getChildren怎么用?PHP Mage_Catalog_Model_Category::getChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Catalog_Model_Category
的用法示例。
在下文中一共展示了Mage_Catalog_Model_Category::getChildren方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: printCategoryChildrenHardWay
protected function printCategoryChildrenHardWay(Mage_Catalog_Model_Category $category)
{
/**
* @var $child Mage_Catalog_Model_Category
* @var $catCollection Mage_Catalog_Model_Resource_Category_Collection
*/
$childrenIds = $category->getChildren();
echo "<p><b> Children Ids: </b>{$childrenIds}</p>";
$catCollection = Mage::getModel('catalog/category')->getCollection();
$catCollection->addIdFilter(explode(',', $childrenIds))->addNameToResult()->load(true, true);
foreach ($catCollection as $child) {
echo "<p> <b>Child cat#{$child->getId()} </b>:: {$child->getName()}</p>";
}
}
示例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: getChildrenCategories
/**
* Retrieve a collection of child categories for the provided category
*
* @param Mage_Catalog_Model_Category $category
* @return Varien_Data_Collection_Db
*/
protected function getChildrenCategories(Mage_Catalog_Model_Category $category)
{
$collection = $category->getCollection();
$collection->addAttributeToSelect('url_key')->addAttributeToSelect('name')->addAttributeToSelect('is_anchor')->addAttributeToFilter('is_active', 1)->addIdFilter($category->getChildren())->setOrder('position', Varien_Db_Select::SQL_ASC)->load();
return $collection;
}
示例4: 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;
}
$children = $category->getChildren();
$hasChildren = $children && $children->count();
$html .= '<li';
if ($hasChildren) {
$html .= ' onmouseover="toggleMenu(this,1)" onmouseout="toggleMenu(this,0)"';
}
$html .= ' class="level' . $level;
if ($this->isCategoryActive($category)) {
$html .= ' active';
}
if ($last) {
$html .= ' last';
}
if ($hasChildren) {
$cnt = 0;
foreach ($children as $child) {
if ($child->getIsActive()) {
$cnt++;
}
}
$html .= ' parent';
}
$html .= '">' . "\n";
$html .= '<a href="' . $this->getCategoryUrl($category) . '"><span>' . $category->getName() . '</span></a>' . "\n";
//$html.= '<span>'.$level.'</span>';
if ($hasChildren) {
$j = 0;
$htmlChildren = '';
foreach ($children as $child) {
$htmlChildren .= $this->drawItem($child, $level + 1, ++$j >= $cnt);
}
if (!empty($htmlChildren)) {
$html .= '<ul class="level' . $level . '">' . "\n" . $htmlChildren . '</ul>';
}
}
$html .= '</li>' . "\n";
return $html;
}
示例5: _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 . '">';
//.........这里部分代码省略.........
示例6: _renderCategorySelectOption
/**
* 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 _renderCategorySelectOption($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();
} else {
$children = $category->getChildren();
}
// select active children
$activeChildren = array();
foreach ($children as $child) {
if ($child->getIsActive()) {
$activeChildren[] = $child;
}
}
$active = '';
if ($this->isCategoryActive($category)) {
$active = 'selected="selected"';
}
// assemble list item with attributes
$html[] = '<option value="' . $this->getCategoryUrl($category) . '" ' . $active . '>' . str_repeat(' ', $level) . $this->escapeHtml($category->getName()) . '</option>';
// render children
$htmlChildren = '';
foreach ($activeChildren as $child) {
$childHtml = $this->_renderCategorySelectOption($child, $level + 1, 0, 0, false, $outermostItemClass, $childrenWrapClass, $noEventAttributes);
$htmlChildren .= $childHtml;
}
if (!empty($htmlChildren)) {
$html[] = $htmlChildren;
}
$html = implode("\n", $html);
return $html;
}
示例7: _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
//.........这里部分代码省略.........
示例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)
{
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;
}
示例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: _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 . ';" />';
//.........这里部分代码省略.........