本文整理汇总了PHP中Mage_Catalog_Model_Category::getIsActive方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Catalog_Model_Category::getIsActive方法的具体用法?PHP Mage_Catalog_Model_Category::getIsActive怎么用?PHP Mage_Catalog_Model_Category::getIsActive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Catalog_Model_Category
的用法示例。
在下文中一共展示了Mage_Catalog_Model_Category::getIsActive方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isCategoryAcceptable
/**
* Checks if a category matches criteria: active && url_key not null && included in menu if it has to
*/
protected static function isCategoryAcceptable(Mage_Catalog_Model_Category $category = null, $mustBeIncludedInNavigation = true)
{
if (!$category->getIsActive() || is_null($category->getUrlKey()) || $mustBeIncludedInNavigation && !$category->getIncludeInMenu()) {
return false;
}
return true;
}
示例2: drawOpenCategoryItem
/**
* @param Mage_Catalog_Model_Category $category
* @param int $level
* @return string
*/
public function drawOpenCategoryItem($category, $level = 0)
{
if ($this->_isExcluded($category->getId()) || !$category->getIsActive()) {
return '';
}
$cssClass = array('amshopby-cat', 'level' . $level);
$currentCategory = $this->getDataHelper()->getCurrentCategory();
if ($currentCategory->getId() == $category->getId()) {
$cssClass[] = 'active';
}
if ($this->isCategoryActive($category)) {
$cssClass[] = 'parent';
}
if ($category->hasChildren()) {
$cssClass[] = 'has-child';
}
$productCount = '';
if ($this->showProductCount()) {
$productCount = $category->getProductCount();
if ($productCount > 0) {
$productCount = ' <span class="count">(' . $productCount . ')</span>';
} else {
$productCount = '';
}
}
$html = array();
$html[1] = '<a href="' . $this->getCategoryUrl($category) . '">' . $this->htmlEscape($category->getName()) . $productCount . '</a>';
$showAll = Mage::getStoreConfig('amshopby/advanced_categories/show_all_categories');
$showDepth = Mage::getStoreConfig('amshopby/advanced_categories/show_all_categories_depth');
$hasChild = false;
$inPath = in_array($category->getId(), $currentCategory->getPathIds());
$showAsAll = $showAll && ($showDepth == 0 || $showDepth > $level + 1);
if ($inPath || $showAsAll) {
$childrenIds = $category->getChildren();
$children = $this->_getCategoryCollection()->addIdFilter($childrenIds);
$this->_getFilterModel()->addCounts($children);
$children = $this->asArray($children);
if ($children && count($children) > 0) {
$hasChild = true;
$htmlChildren = '';
foreach ($children as $child) {
$htmlChildren .= $this->drawOpenCategoryItem($child, $level + 1);
}
if ($htmlChildren != '') {
$cssClass[] = 'expanded';
$html[2] = '<ol>' . $htmlChildren . '</ol>';
}
}
}
$html[0] = sprintf('<li class="%s">', implode(" ", $cssClass));
$html[3] = '</li>';
ksort($html);
if ($category->getProductCount() || $hasChild && $htmlChildren) {
$result = implode('', $html);
} else {
$result = '';
}
return $result;
}
示例3: linktoCategoryThumbnail
/**
* linktoCategoryThumbnail
*
* wraps the category thumbnail with a link to the category
*
* @param Mage_Catalog_Model_Category $category
* @param string $linkCss # CSS classes
* @param integer|string $width # thumbnail width
* @param integer|string $height # thumbnail height
* @return string
*/
public function linktoCategoryThumbnail(Mage_Catalog_Model_Category $category, $linkCss = '', $width = 168, $height = 168)
{
$link = '';
if ($category->getIsActive()) {
$catUrl = $category->getUrl();
$catName = $this->htmlEscape($category->getName());
$catThumbnail = self::displayCategoryThumbnail($category, $width, $height);
$link = "\n <a class='{$linkCss}' href='{$catUrl}' title='{$catName}'>\n {$catThumbnail}\n <span class='category-name'>{$catName}</span>\n </a>\n ";
}
return $link;
}
示例4: exportData
protected function exportData(Mage_Catalog_Model_Category $category, $file, $depth = 0)
{
$data = array('id' => $category->getId(), 'parent_id' => $category->getParentId(), 'attribute_set_id' => $category->getAttributeSetId(), 'urlPath' => $category->getUrlPath(), 'urlKey' => $category->getUrlKey(), 'path' => $category->getPath(), 'position' => $category->getPosition(), 'page_layout' => $category->getPageLayout(), 'description' => $category->getDescription(), 'display_mode' => $category->getDisplayMode(), 'is_active' => $category->getIsActive(), 'is_anchor' => $category->getIsAnchor(), 'include_in_menu' => $category->getIncludeInMenu(), 'custom_design' => $category->getCustomDesign(), 'level' => $category->getLevel(), 'name' => $category->getName(), 'metaTitle' => $category->getMetaTitle(), 'metaKeywords' => $category->getMetaKeywords(), 'metaDescription' => $category->getMetaDescription());
echo str_repeat(' ', $depth);
echo '* ' . $category->getName() . sprintf(' (%s products)', $category->getProductCount()) . PHP_EOL;
fputcsv($file, $data);
if ($category->hasChildren()) {
$children = Mage::getModel('catalog/category')->getCategories($category->getId());
foreach ($children as $child) {
$child = Mage::getModel('catalog/category')->load($child->getId());
$this->exportData($child, $file, $depth + 1);
}
}
}
示例5: 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 (!$last) {
$html .= '┗';
} else {
$html .= '┣';
}
$html .= '<a href="' . $this->getCategoryUrl($category) . '"><span>' . $this->htmlEscape($category->getName()) . '</span></a><br/>';
return $html;
}
示例6: 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;
}
示例7: 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;
}
示例8: 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()] = ltrim($parentname . " / " . $category->getName(), " / ");
}
// get all children
$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, $parentname . " / " . $category->getName());
foreach ($childarray as $k => $v) {
$ret[$k] = ltrim($v, " / ");
}
}
return $ret;
}
示例9: _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;
}
示例10: _renderCategoryMenuItemHtml
/**
* @param Mage_Catalog_Model_Category $category
* @param int $level
* @param bool $isLast
* @param bool $isFirst
* @param bool $isOutermost
* @param string $outermostItemClass
* @param string $childrenWrapClass
* @param bool $noEventAttributes
* @return array|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;
}
}
$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;
if ($this->brandmanager_category_id == $category->getId()) {
$html[] = '<li class="view-all-link">';
$html[] = '<a href="' . $this->getCategoryUrl($category) . '"' . $linkClass . '>';
$html[] = '<span>View All</span>';
$html[] = '</a>';
$html[] = '</li>';
}
$html[] = '</ul>';
if ($childrenWrapClass) {
$html[] = '</div>';
//.........这里部分代码省略.........
示例11: drawOpenCategoryItem
/**
* Enter description here...
*
* @param Mage_Catalog_Model_Category $category
* @return string
*/
public function drawOpenCategoryItem($category)
{
$html = '';
if (!$category->getIsActive()) {
return $html;
}
$html .= '<li';
if ($this->isCategoryActive($category)) {
$html .= ' class="active"';
}
$html .= '>' . "\n";
$html .= '<a href="' . $this->getCategoryUrl($category) . '"><span>' . $this->htmlEscape($category->getName()) . '</span></a>' . "\n";
if (in_array($category->getId(), $this->getCurrentCategoryPath())) {
$children = $category->getChildren();
$hasChildren = $children && $children->count();
if ($hasChildren) {
$htmlChildren = '';
foreach ($children as $child) {
$htmlChildren .= $this->drawOpenCategoryItem($child);
}
if (!empty($htmlChildren)) {
$html .= '<ul>' . "\n" . $htmlChildren . '</ul>';
}
}
}
$html .= '</li>' . "\n";
return $html;
}
示例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 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 {
//.........这里部分代码省略.........
示例13: _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
//.........这里部分代码省略.........
示例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 '';
}
$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 . ';" />';
//.........这里部分代码省略.........
示例15: _prepareItemData
/**
* @param Mage_Catalog_Model_Category $category
* @param $isSelected
* @param int $level
* @param bool $isFolded
* @param bool $addCount
* @return array|null
*/
protected function _prepareItemData($category, $isSelected, $level = 1, $isFolded = false, $addCount = false)
{
$row = null;
/*
* Display only active category and having products or being parents
*/
if ($category->getIsActive() && (!$addCount || $category->getProductCount())) {
$row = array('label' => Mage::helper('core')->htmlEscape($category->getName()), 'value' => $this->getCategoryUrl($category), 'count' => $addCount ? $this->_getProductCount($category) : 0, 'level' => $level, 'id' => $category->getId(), 'parent_id' => $category->getParentId(), 'is_folded' => $isFolded, 'is_selected' => $isSelected);
}
return $row;
}