Warning: get_class() expects parameter 1 to be object, boolean given - magento

I'm having a problem that's been in some way posted here before but never for this case. Usually this error occurs in App.php but for me it's occurring in /httpdocs/app/design/frontend/default/theme/template/catalog/category/view.phtml on line 42 which I've indicated below.
Does anyone have any idea on the fix for this? I'm a bit at a loss.
<?php
/**
* Category view template
*
* #see Mage_Catalog_Block_Category_View
*/
?>
<?php
$_helper = $this->helper('catalog/output');
$_category = $this->getCurrentCategory();
$_imgHtml = '';
$_category->setCanShowBlock(false);
$_category->setHasHeaderImage(false);
//////Line 42/////// if (get_class($this->getLayout()->getBlock('catalog.leftnav')) != 'Mage_Catalog_Block_Navigation') {
$_category->setCanShowBlock($this->getLayout()->getBlock('mana.catalog.leftnav')->canShowBlock());
}
if ($_imgUrl = $_category->getImageUrl()) {
$_imgHtml = '<img src="'.$_imgUrl.'" alt="'.$this->htmlEscape($_category->getName()).'" title="'.$this->htmlEscape($_category->getName()).'" />';
$_imgHtml = $_helper->categoryAttribute($_category, $_imgHtml, 'image');
$_category->setHasHeaderImage(true);
}
?>
<?php /*
<!-- <div class="page-title category-title">
<?php if($this->IsRssCatalogEnable() && $this->IsTopCategory()): ?>
<?php echo $this->__('Subscribe to RSS Feed') ?>
<?php endif; ?>
<h1><img src="<?php echo $this->getSkinUrl('images/' . $_helper->categoryAttribute($_category, $_category->getName(), 'name') . '.jpg') ?>" alt="<?php echo $_helper->categoryAttribute($_category, $_category->getName(), 'name') ?>" /></h1>
</div> -->
*/
Mage::getModel('core/session')->setHasAdditionalDescription(false);
?>
<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
<div id="category_top_image"<?php if ($_category->getCanShowBlock()): ?> style="margin-left: -280px;"<?php endif ?>>
<?php if($_imgUrl): ?>
<?php echo $_imgHtml ?>
<?php endif; ?>
<?php if(strtolower($_category->getHideTitle()) != 'yes'): ?>
<h1><?php echo $_helper->categoryAttribute($_category, $_category->getName(), 'name') ?></h1>
<?php endif ?>
<?php if($_description=$this->getCurrentCategory()->getDescription()): ?>
<div class="category-description std">
<?php echo $_helper->categoryAttribute($_category, $_description, 'description') ?>
</div>
<?php endif; ?>
</div>
<?php if($this->isContentMode()): ?>
<?php echo $this->getCmsBlockHtml() ?>
<?php elseif($this->isMixedMode()): ?>
<?php echo $this->getCmsBlockHtml() ?>
<?php if($_description=$this->getCurrentCategory()->getAdditionalDescription()): ?>
<?php Mage::getModel('core/session')->setHasAdditionalDescription(true) ?>
<div class="category-additional-description std">
<?php echo $_helper->categoryAttribute($_category, $_description, 'additional_description') ?>
</div>
<?php endif; ?>
<?php echo $this->getProductListHtml() ?>
<?php else: ?>
<?php if($_description=$this->getCurrentCategory()->getAdditionalDescription()): ?>
<?php Mage::getModel('core/session')->setHasAdditionalDescription(true) ?>
<div class="category-additional-description std">
<?php echo $_helper->categoryAttribute($_category, $_description, 'additional_description') ?>
</div>
<?php endif; ?>
<?php echo $this->getProductListHtml() ?>
<?php endif; ?>

Well, that error means that there is no block named catalog.leftnav on the page, so you should check your layouts. And actually this way of checking class is bad since it leads to such errors. Also there will be a problem, if some extension will rewrite Mage_Catalog_Block_Navigation class.
So I'm not sure why do you want to check the class of that block, but if you really need it, I would suggest something less risky and rewrite-friendly:
if ($block = $this->getLayout()->getBlock('catalog.leftnav') && $block instanceof Mage_Catalog_Block_Navigation) {
...
}

Related

I want to display an option list for configurable attributes on product list page in magento

I want to display an option list for configurable attributes on product list page in magento, just like it appears on product view page for configurable products.I tried everything but nothing is working, looked for some similar topics but they are useless.Please help me resolve this issue.
<?php
$_productCollection=$this->getLoadedProductCollection();
$_helper = $this->helper('catalog/output');
$sidebar=Mage::getStoreConfig('buyshoplayout/product_listing/sidebar');
$i=0;
$count=0;
$span=3;
$p_in_row=4;
$type=Mage::getStoreConfig('buyshoplayout/product_listing/product_listing_image_size');
if($type=='small')
{
$span=2;
$p_in_row=6;
}
?>
<?php if(!$_productCollection->count()): ?>
<div class="category-products aligncenter">
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('buyshop_no_products')->toHtml() ?>
</div>
<?php else: ?>
<div class="category-products">
<?php echo $this->getToolbarHtml() ?>
<?php // List mode ?>
<?php if($this->getMode()!='grid'): ?>
<?php foreach ($_productCollection as $_product): ?>
<?php
$widthBig=258;
$heightBig=245;
$widthSmall=71;
$heightSmall=65;
$count++;
?>
<!--PRODUCT-->
<div class="row product-listing">
<?php echo Mage::helper('buyshopconfig')->getProductHtml($_product,$this,$widthBig,$heightBig,$span,false,true,true,false,$this->getPriceHtml($_product, true))?>
<div class="span6 product-detailes">
<h3 class="product-name bottom-line"><?php echo $this->stripTags($_product->getName(), null, true)?></h3>
<div class="bottom-line">
<?php echo $this->getPriceHtml($_product, true) ?>
<div class="product-review">
<?php echo Mage::helper('buyshopconfig')->getStars($_product)?>
</div>
</div>
<div class="bottom-line"><?php echo $_helper->productAttribute($_product, $_product->getShortDescription(), 'short_description') ?></div>
<div class="product-buttons">
<?php echo Mage::helper('buyshopconfig')->addToCartLink($_product,$this,true)?>
<div class="add-to-links">
<ul>
<?php echo Mage::helper('buyshopconfig')->addWishCompLink($_product,$this,true)?>
</ul>
</div>
</div>
</div>
</div>
<!--PRODUCT EOF-->
<?php endforeach; ?>
<?php else: ?>
<?php // Grid Mode ?>
<?php if(!empty(Mage::registry('current_category')->name)):?>
<h2><?php echo Mage::registry('current_category')->name ?></h2>
<?php endif; ?>
<?php if($sidebar):?><div class="row big_with_description"><?php endif; ?>
<?php foreach ($_productCollection as $_product): ?>
<?php if(!$_product->isSaleable() && !Mage::getStoreConfig('cataloginventory/options/show_out_of_stock'))continue; ?>
<?php
$widthBig=258;
$heightBig=245;
$widthSmall=71;
$heightSmall=65;
$count++;
?>
<?php
if(!$sidebar)
{
$i++;
if($i==1)echo '<div class="row big_with_description">';
}
$price=$this->getPriceHtml($_product, true);
?>
<!--PRODUCT-->
<?php echo Mage::helper('buyshopconfig')->getProductHtml($_product,$this,$widthBig,$heightBig,$span,false,true,false,true,$price)?>
<?php echo Mage::helper('buyshopconfig')->getProductHover($_product,$this,$widthBig,$heightBig,$widthSmall,$heightSmall,$type,true,true,$price)?>
<!--PRODUCT EOF-->
<?php
if(!$sidebar)
{
if($i==$p_in_row || $count==count($_productCollection))
{
echo '</div>';
$i=0;
}
}
?>
<?php endforeach; ?>
<?php if($sidebar):?></div><?php endif; ?>
<?php endif; ?>
<?php echo $this->getToolbarHtml() ?>
</div>
<?php endif; ?>

How to display Option List in wishlist sidebar magento

How to display Option List in wishlist sidebar magento?
I use this code!
However, it is not working. Thanks in advance.
<?php if ($_options = $this->getOptionList()):?>
<div class="truncated">
<div class="truncated_full_value">
<dl class="item-options">
<?php foreach ($_options as $_option) : ?>
<dt><?php echo $this->escapeHtml($_option['label']) ?></dt>
<dd>
<?php if (is_array($_option['value'])): ?>
<?php echo nl2br(implode("\n", $_option['value'])) ?>
<?php else: ?>
<?php echo $_option['value'] ?>
<?php endif; ?>
</dd>
<?php endforeach; ?>
</dl>
</div>
<?php echo $this->__('Details') ?>
</div>
<?php endif; ?>
try this:
<?php $options = $this->getOptionList(); ?>
<?php if ($options): ?>
<div class="truncated">
<div class="truncated_full_value">
<div class="item-options">
<p><?php echo $this->__('Options Details'); ?></p>
<dl>
<?php foreach ($options as $option): ?>
<dt><?php echo $this->escapeHtml($option['label']) ?></dt>
<dd>
<?php if (is_array($option['value'])): ?>
<?php echo nl2br(implode("\n", $option['value'])) ?>
<?php else: ?>
<?php echo $option['value'] ?>
<?php endif; ?>
</dd>
<?php endforeach; ?>
</dl>
</div>
</div>
<?php echo $this->__('View Details') ?>
</div>
<?php endif ?>

count subcategory of current category in magento

magento,in if statement im using a condition for two option, first one is current category has zero sub category and second one is current category has more than zero subcategory, but this condition is not working with this code
<?php $helper = $this->helper('catalog/category') ?>
<?php $categories = $this->getStoreCategories() ?>
<?php if (count($categories) > 0): ?>
<?php $_filters = $this->getFilters() ?>
<?php foreach ($_filters as $_filter): ?>
<?php if($_filter->getName() == 'Brand' || $_filter->getName() == 'Category' || $_filter->getName() == 'Store' || $_filter->getName() == 'Price' ): ?>
<?php if($_filter->getItemsCount()): ?>
<dt><div style="background-color:#cdcdcd;padding:4px;border-radius:3px;"><?php echo $this->__($_filter->getName()) ?></div></dt>
<dd><div style="max-height:150px;overflow:auto;padding-top:5px;"><?php echo $_filter->getHtml() ?></div></dd>
<?php endif; ?>
<?php endif; ?>
<?php endforeach; ?>
<?php else : ?>
<?php $_filters = $this->getFilters() ?>
<?php foreach ($_filters as $_filter): ?>
<?php if($_filter->getItemsCount()): ?>
<dt>
<div style="background-color:#cdcdcd;padding:4px;border-radius:3px;"><?php echo $this->__($_filter->getName()) ?></div>
<?php if ($removeUrl = Mage::helper('layerednavigation')->getRemoveUrl($_filter)): ?>
<a class="btn-remove" href="<?php echo $removeUrl ?>" title="<?php echo $this->__('Clear All') ?>"><?php echo $this->__('Clear All') ?></a>
<?php endif ?>
</dt>
<dd><div style="max-height:150px;overflow:auto;padding-top:5px;"><?php echo $_filter->getHtml() ?></div></dd>
<?php endif; ?>
<?php endforeach; ?>
<?php endif; ?>
</dl>
<script type="text/javascript">decorateDataList('narrow-by-list')</script>
<?php endif; ?>
ckeck its first statement and give me solution
Hello check below code may be help you
<?php
$layer = Mage::getSingleton('catalog/layer');
$_category = $layer->getCurrentCategory();
$currentCategoryId= $_category->getId();
$children = Mage::getModel('catalog/category')->getCategories($currentCategoryId);
$countSubcategory=0;
foreach ($children as $category)
{
$countSubcategory++;
}
echo $countSubcategory;
?>

Alternative layout is applied to an article but not the other

I'm using Joomla 3.x and create an article override. It works fine for some articles. But when I apply to another article, inside a single article menu item, it not work.
UPDATE
Here is my entire override file:
<?php
/**
* #package Joomla.Site
* #subpackage com_content
*
* #copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* #license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers');
// Create shortcuts to some parameters.
$params = $this->item->params;
$images = json_decode($this->item->images);
$urls = json_decode($this->item->urls);
$canEdit = $params->get('access-edit');
$user = JFactory::getUser();
$info = $params->get('info_block_position', 0);
JHtml::_('behavior.caption');
?>
<div class="item-page<?php echo $this->pageclass_sfx?>">
<?php if ($this->params->get('show_page_heading') && $params->get('show_title')) : ?>
<div class="page-header">
<h1> <?php echo $this->escape($this->params->get('page_heading')); ?> </h1>
</div>
<?php endif;
if (!empty($this->item->pagination) && $this->item->pagination && !$this->item->paginationposition && $this->item->paginationrelative)
{
echo $this->item->pagination;
}
?>
<?php if ($params->get('show_title') || $params->get('show_author')) : ?>
<div class="page-header">
<h2>
<?php if ($this->item->state == 0) : ?>
<span class="label label-warning"><?php echo JText::_('JUNPUBLISHED'); ?></span>
<?php endif; ?>
<?php if ($params->get('show_title')) : ?>
<?php if ($params->get('link_titles') && !empty($this->item->readmore_link)) : ?>
<?php echo $this->escape($this->item->title); ?>
<?php else : ?>
<?php echo $this->escape($this->item->title); ?>
<?php endif; ?>
<?php endif; ?>
</h2>
<p class="date-created"><?php echo JText::sprintf('COM_CONTENT_CREATED_DATE_ON', JHtml::_('date', $this->item->created, JText::_('DATE_FORMAT_LC3'))); ?></p>
</div>
<?php endif; ?>
<?php if (!$this->print) : ?>
<?php if ($canEdit || $params->get('show_print_icon') || $params->get('show_email_icon')) : ?>
<div class="btn-group pull-right">
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#"> <span class="icon-cog"></span> <span class="caret"></span> </a>
<?php // Note the actions class is deprecated. Use dropdown-menu instead. ?>
<ul class="dropdown-menu actions">
<?php if ($params->get('show_print_icon')) : ?>
<li class="print-icon"> <?php echo JHtml::_('icon.print_popup', $this->item, $params); ?> </li>
<?php endif; ?>
<?php if ($params->get('show_email_icon')) : ?>
<li class="email-icon"> <?php echo JHtml::_('icon.email', $this->item, $params); ?> </li>
<?php endif; ?>
<?php if ($canEdit) : ?>
<li class="edit-icon"> <?php echo JHtml::_('icon.edit', $this->item, $params); ?> </li>
<?php endif; ?>
</ul>
</div>
<?php endif; ?>
<?php else : ?>
<div class="pull-right">
<?php echo JHtml::_('icon.print_screen', $this->item, $params); ?>
</div>
<?php endif; ?>
<?php $useDefList = ($params->get('show_modify_date') || $params->get('show_publish_date') || $params->get('show_create_date')
|| $params->get('show_hits') || $params->get('show_category') || $params->get('show_parent_category') || $params->get('show_author')); ?>
<?php if ($useDefList && ($info == 0 || $info == 2)) : ?>
<div class="article-info muted">
<dl class="article-info">
<!--<dt class="article-info-term"><?php echo JText::_('COM_CONTENT_ARTICLE_INFO'); ?></dt>-->
<?php if ($params->get('show_author') && !empty($this->item->author )) : ?>
<dd class="createdby">
<?php $author = $this->item->created_by_alias ? $this->item->created_by_alias : $this->item->author; ?>
<?php if (!empty($this->item->contactid) && $params->get('link_author') == true) : ?>
<?php
$needle = 'index.php?option=com_contact&view=contact&id=' . $this->item->contactid;
$menu = JFactory::getApplication()->getMenu();
$item = $menu->getItems('link', $needle, true);
$cntlink = !empty($item) ? $needle . '&Itemid=' . $item->id : $needle;
?>
<?php echo JText::sprintf('COM_CONTENT_WRITTEN_BY', JHtml::_('link', JRoute::_($cntlink), $author)); ?>
<?php else: ?>
<?php echo JText::sprintf('COM_CONTENT_WRITTEN_BY', $author); ?>
<?php endif; ?>
</dd>
<?php endif; ?>
<?php if ($params->get('show_parent_category') && !empty($this->item->parent_slug)) : ?>
<dd class="parent-category-name">
<?php $title = $this->escape($this->item->parent_title);
$url = ''.$title.'';?>
<?php if ($params->get('link_parent_category') && !empty($this->item->parent_slug)) : ?>
<?php echo JText::sprintf('COM_CONTENT_PARENT', $url); ?>
<?php else : ?>
<?php echo JText::sprintf('COM_CONTENT_PARENT', $title); ?>
<?php endif; ?>
</dd>
<?php endif; ?>
<?php if ($params->get('show_category')) : ?>
<dd class="category-name">
<?php $title = $this->escape($this->item->category_title);
$url = '' . $title . '';?>
<?php if ($params->get('link_category') && $this->item->catslug) : ?>
<?php echo JText::sprintf('COM_CONTENT_CATEGORY', $url); ?>
<?php else : ?>
<?php echo JText::sprintf('COM_CONTENT_CATEGORY', $title); ?>
<?php endif; ?>
</dd>
<?php endif; ?>
<?php if ($params->get('show_publish_date')) : ?>
<dd class="published">
<!--<span class="icon-calendar"></span>--> <?php echo JText::sprintf('COM_CONTENT_PUBLISHED_DATE_ON', JHtml::_('date', $this->item->publish_up, JText::_('DATE_FORMAT_LC3'))); ?>
</dd>
<?php endif; ?>
<?php if ($info == 0) : ?>
<?php if ($params->get('show_modify_date')) : ?>
<dd class="modified">
<!--<span class="icon-calendar"></span>--> <?php echo JText::sprintf('COM_CONTENT_LAST_UPDATED', JHtml::_('date', $this->item->modified, JText::_('DATE_FORMAT_LC3'))); ?>
</dd>
<?php endif; ?>
<?php if ($params->get('show_create_date')) : ?>
<dd class="create">
<!--<span class="icon-calendar"></span>--> <?php echo JText::sprintf('COM_CONTENT_CREATED_DATE_ON', JHtml::_('date', $this->item->created, JText::_('DATE_FORMAT_LC3'))); ?>
</dd>
<?php endif; ?>
<?php if ($params->get('show_hits')) : ?>
<dd class="hits">
<span class="icon-eye-open"></span> <?php echo JText::sprintf('COM_CONTENT_ARTICLE_HITS', $this->item->hits); ?>
</dd>
<?php endif; ?>
<?php endif; ?>
</dl>
</div>
<?php endif; ?>
<?php if (!$params->get('show_intro')) : echo $this->item->event->afterDisplayTitle; endif; ?>
<?php echo $this->item->event->beforeDisplayContent; ?>
<?php if (isset($urls) && ((!empty($urls->urls_position) && ($urls->urls_position == '0')) || ($params->get('urls_position') == '0' && empty($urls->urls_position)))
|| (empty($urls->urls_position) && (!$params->get('urls_position')))) : ?>
<?php echo $this->loadTemplate('links'); ?>
<?php endif; ?>
<?php if ($params->get('access-view')):?>
<?php if (isset($images->image_fulltext) && !empty($images->image_fulltext)) : ?>
<?php $imgfloat = (empty($images->float_fulltext)) ? $params->get('float_fulltext') : $images->float_fulltext; ?>
<div class="pull-<?php echo htmlspecialchars($imgfloat); ?> item-image"> <img
<?php if ($images->image_fulltext_caption):
echo 'class="caption"'.' title="' .htmlspecialchars($images->image_fulltext_caption) . '"';
endif; ?>
src="<?php echo htmlspecialchars($images->image_fulltext); ?>" alt="<?php echo htmlspecialchars($images->image_fulltext_alt); ?>"/> </div>
<?php endif; ?>
<?php
if (!empty($this->item->pagination) && $this->item->pagination && !$this->item->paginationposition && !$this->item->paginationrelative):
echo $this->item->pagination;
endif;
?>
<?php if (isset ($this->item->toc)) :
echo $this->item->toc;
endif; ?>
<div class="article-text"><?php echo $this->item->text; ?></div>
<?php if ($useDefList && ($info == 1 || $info == 2)) : ?>
<div class="article-info muted">
<dl class="article-info">
<!--<dt class="article-info-term"><?php echo JText::_('COM_CONTENT_ARTICLE_INFO'); ?></dt>-->
<?php if ($info == 1) : ?>
<?php if ($params->get('show_author') && !empty($this->item->author )) : ?>
<dd class="createdby">
<?php $author = $this->item->created_by_alias ? $this->item->created_by_alias : $this->item->author; ?>
<?php if (!empty($this->item->contactid) && $params->get('link_author') == true) : ?>
<?php
$needle = 'index.php?option=com_contact&view=contact&id=' . $this->item->contactid;
$menu = JFactory::getApplication()->getMenu();
$item = $menu->getItems('link', $needle, true);
$cntlink = !empty($item) ? $needle . '&Itemid=' . $item->id : $needle;
?>
<?php echo JText::sprintf('COM_CONTENT_WRITTEN_BY', JHtml::_('link', JRoute::_($cntlink), $author)); ?>
<?php else: ?>
<?php echo JText::sprintf('COM_CONTENT_WRITTEN_BY', $author); ?>
<?php endif; ?>
</dd>
<?php endif; ?>
<?php if ($params->get('show_parent_category') && !empty($this->item->parent_slug)) : ?>
<dd class="parent-category-name">
<?php $title = $this->escape($this->item->parent_title);
$url = '' . $title . '';?>
<?php if ($params->get('link_parent_category') && $this->item->parent_slug) : ?>
<?php echo JText::sprintf('COM_CONTENT_PARENT', $url); ?>
<?php else : ?>
<?php echo JText::sprintf('COM_CONTENT_PARENT', $title); ?>
<?php endif; ?>
</dd>
<?php endif; ?>
<?php if ($params->get('show_category')) : ?>
<dd class="category-name">
<?php $title = $this->escape($this->item->category_title);
$url = '' . $title . '';?>
<?php if ($params->get('link_category') && $this->item->catslug) : ?>
<?php echo JText::sprintf('COM_CONTENT_CATEGORY', $url); ?>
<?php else : ?>
<?php echo JText::sprintf('COM_CONTENT_CATEGORY', $title); ?>
<?php endif; ?>
</dd>
<?php endif; ?>
<?php if ($params->get('show_publish_date')) : ?>
<dd class="published">
<!--<!--<span class="icon-calendar"></span>-->-->
<?php echo JText::sprintf('COM_CONTENT_PUBLISHED_DATE_ON', JHtml::_('date', $this->item->publish_up, JText::_('DATE_FORMAT_LC3'))); ?>
</dd>
<?php endif; ?>
<?php endif; ?>
<?php if ($params->get('show_create_date')) : ?>
<dd class="create">
<!--<!--<span class="icon-calendar"></span>-->-->
<?php echo JText::sprintf('COM_CONTENT_CREATED_DATE_ON', JHtml::_('date', $this->item->modified, JText::_('DATE_FORMAT_LC3'))); ?>
</dd>
<?php endif; ?>
<?php if ($params->get('show_modify_date')) : ?>
<dd class="modified">
<!--<span class="icon-calendar"></span>-->
<?php echo JText::sprintf('COM_CONTENT_LAST_UPDATED', JHtml::_('date', $this->item->modified, JText::_('DATE_FORMAT_LC3'))); ?>
</dd>
<?php endif; ?>
<?php if ($params->get('show_hits')) : ?>
<dd class="hits">
<span class="icon-eye-open"></span> <?php echo JText::sprintf('COM_CONTENT_ARTICLE_HITS', $this->item->hits); ?>
</dd>
<?php endif; ?>
</dl>
</div>
<?php endif; ?>
<?php
if (!empty($this->item->pagination) && $this->item->pagination && $this->item->paginationposition && !$this->item->paginationrelative):
echo $this->item->pagination;
?>
<?php endif; ?>
<?php if (isset($urls) && ((!empty($urls->urls_position) && ($urls->urls_position == '1')) || ($params->get('urls_position') == '1'))) : ?>
<?php echo $this->loadTemplate('links'); ?>
<?php endif; ?>
<?php //optional teaser intro text for guests ?>
<?php elseif ($params->get('show_noauth') == true && $user->get('guest')) : ?>
<?php echo $this->item->introtext; ?>
<?php //Optional link to let them register to see the whole article. ?>
<?php if ($params->get('show_readmore') && $this->item->fulltext != null) :
$link1 = JRoute::_('index.php?option=com_users&view=login');
$link = new JURI($link1);?>
<p class="readmore">
<a href="<?php echo $link; ?>">
<?php $attribs = json_decode($this->item->attribs); ?>
<?php
if ($attribs->alternative_readmore == null) :
echo JText::_('COM_CONTENT_REGISTER_TO_READ_MORE');
elseif ($readmore = $this->item->alternative_readmore) :
echo $readmore;
if ($params->get('show_readmore_title', 0) != 0) :
echo JHtml::_('string.truncate', ($this->item->title), $params->get('readmore_limit'));
endif;
elseif ($params->get('show_readmore_title', 0) == 0) :
echo JText::sprintf('COM_CONTENT_READ_MORE_TITLE');
else :
echo JText::_('COM_CONTENT_READ_MORE');
echo JHtml::_('string.truncate', ($this->item->title), $params->get('readmore_limit'));
endif; ?>
</a>
</p>
<?php endif; ?>
<?php endif; ?>
<?php
if (!empty($this->item->pagination) && $this->item->pagination && $this->item->paginationposition && $this->item->paginationrelative) :
echo $this->item->pagination;
?>
<?php endif; ?>
<?php echo $this->item->event->afterDisplayContent; ?> </div>
UPDATE 2
I discovered one thing: if the article is associated with a menu item (type:Category List), the Alternative Layout works. But when the article is associated a menu item (type:Single Article), the Alternative Layout does not work. How do the Alternative Layout function in both cases?
SOLVED!
I Create a custom menu item type.
More informations here: http://docs.joomla.org/Layout_Overrides_in_Joomla_2.5
And here: http://jure-stern.si/blog/custom-menu-item-types-in-joomla-with-xml-files/

Magento: Can't get categories children

For some reason this code is returning NULL when trying to get a categories subcategories.
<?php var_dump($_category->getChildrenCategories()); ?>
Here is the full code from a .phmtl file.
<ul id="nav_vert">
<?php foreach ($this->getStoreCategories() as $_category): ?>
<?php if ($_category->getIsActive()) { ?>
<?php $open = $this->isCategoryActive($_category); ?>
<?php $potential = $_category->hasChildren(); ?>
<li><a href="<?php echo $this->getCategoryUrl($_category); ?>"<?php if($open) { echo ' class="open"'; } ?><?php if($potential) { echo ' class="potential"'; } ?> ><?php if($potential&&$open) { echo 'v '; } elseif($potential) { echo '> '; }else{ echo ' '; }?><?php echo $_category->getName();?></a>
<?php if ($open && $potential): ?>
<?php var_dump($_category->getChildrenCategories()); ?>
<ul>
<?php foreach ($_category->getChildrenCategories() as $subcategory): ?>
<?php $subCat = Mage::getModel('catalog/category')->load($subcategory); ?>
<?php $open = $this->isCategoryActive($subCat); ?>
<?php $potential = $subCat->hasChildren(); ?>
<li><a href="<?php echo $this->getCategoryUrl($subCat); ?>"<?php if($open) { echo ' class="subopen"'; } ?><?php if($potential) { echo ' class="potential"'; } ?><?php if(!$potential&&$open) { echo ' class="final"'; } ?> ><?php if($potential&&$open) { echo ':: '; } elseif($potential) { echo '> '; }?><?php echo $subCat->getName(); ?> (<?php echo $subCat->getProductCount(); ?>)</a>
<?php if ($open && $potential): ?>
<ul>
<?php foreach ($subcategory->getChildrenCategories() as $subsubcategory): ?>
<?php $subsubCat = Mage::getModel('catalog/category')->load($subsubcategory); ?>
<?php $open = $this->isCategoryActive($subsubCat) ?>
<li><a href="<?php echo $this->getCategoryUrl($subsubCat); ?>" <?php if($open) { echo ' class="final"'; } ?>><?php echo $subsubCat->getName(); ?> (<?php echo $subsubCat->getProductCount(); ?>)</a></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</li>
<?php } ?>
<?php endforeach ?>
</ul>
This line always returns true
<?php $potential = $_category->hasChildren(); ?>
And I know that the category has children.
Can anyone suggest why this doesn't work?
This is how I place the phtml in the page:
<reference name="left">
<block type="catalog/navigation" name="catalog.vertnav" template="catalog/navigation/vert_nav.phtml" before="-" />
</reference>
Magento version 1.5.1.0
Try using $_category->getChildren() (instead of $_category->getChildrenCategories() )
Have an easy day,
Pesach
You might also like to try this,
foreach ($_category->getCategories($_category) as $subcategory):
getCategories() is a more complex form but it allows you more control too. By specifying a recursion level you can retrieve not just the children but grand-children too...
Try with this code,
$this->getCurrentCategory()->getChildrenCategories()
Hope this helps
<?php $helper = $this->helper('catalog/category') ?>
<?php $categories = $this->getStoreCategories() ?>
<?php foreach($categories as $category): ?>
<?php $subcategories = $category->getChildren() ?>
<?php foreach($subcategories as $subcategory): ?>
<?php $subsubcategories = $subcategory->getChildren() ?>
<?php foreach($subsubcategories as $subsubcategory): ?>
<?php endforeach; ?><!-- end foreach subsubcategories -->
<?php endforeach; ?><!-- end foreach subcategories -->
<?php endforeach; ?><!-- end foreach categories -->
This is the basic idea behind extracting children categories.
So accordingly you can work on it.

Resources