I have the following code in a custom block that is referenced in my three column layout. To get the category banner to show at the very top of each category page.
<?php
$_helper = $this->helper('catalog/output');
$_category = $this->getCurrentCategory();
$_imgHtml = '';
if ($_imgUrl = $_category->getImageUrl()) {
$_imgHtml = '<p class="category-image"><img src="'.$_imgUrl.'" alt="'.$this->escapeHtml($_category->getName()).'" title="'.$this->escapeHtml($_category->getName()).'" /></p>';
$_imgHtml = $_helper->categoryAttribute($_category, $_imgHtml, 'image');
}
?>
<?php if($_imgUrl): ?>
<?php echo $_imgHtml ?>
<?php endif; ?>
However I get a fatal call to object error, can anyone help? I've tried a simple echo hello to test there's nothing wrong with the block. So there's some issue with the code above. Thank you.
Here's the error..
fatal error: Call to a member function getImageUrl() on a non-object in /home/website/public_html/app/design/frontend/mytheme/default/template/custom/category/top_banner.phtml on line 5