Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

How do I move the category image to underneath the top navigation? 
 
heather.ph
Jr. Member
 
Total Posts:  16
Joined:  2010-10-04
 

I want to insert a different top banner for each category page. I know I can insert a category image by uploading it in the ‘manage categories’ section in the admin panel, but this inserts it into the middle column.

I’d like to move it to beneath the navigation bar.

I’ve seen this code in view.phtml but I want to position the image above if you know what I mean!

<?php
    $_helper    
$this->helper('catalog/output');
    
$_category  $this->getCurrentCategory();
    
$_imgHtml   '';
    if (
$_imgUrl $_category->getImageUrl()) {
        $_imgHtml 
'<p class="category-image"><img src="'.$_imgUrl.'" alt="'.$this->htmlEscape($_category->getName()).'" title="'.$this->htmlEscape($_category->getName()).'" /></p>';
        
$_imgHtml $_helper->categoryAttribute($_category$_imgHtml'image');
    
}
?>

I’ve attached to images, the first ‘site.jpg’ is how it looks now. The second ‘banner.jpg’ is how I want it to look.

Any help would be greatly appreciated. I’m getting my head into magento but there are a few things I am unsure how to do.

Thanks!  LOL

Image Attachments
site.jpgbanner.jpg
 
Magento Community Magento Community
Magento Community
Magento Community
 
heather.ph
Jr. Member
 
Total Posts:  16
Joined:  2010-10-04
 

It’s ok I figured it out smile

My solution was:

Create cat_img.phtml in app\design\frontend\base\theme063\template\catalog\category
Put in this code:

<?php if($_imageUrl=$this->getCurrentCategory()->getImageUrl()): ?>
        
<class="category-image"><img src="<?php echo $_imageUrl ?>" alt="<?php echo $this->htmlEscape($this->getCurrentCategory()->getName()) ?>" /></p>
    
<?php endif; ?>

In page.xml add under breadcrumbs.

<block type="catalog/category_view" name="category_banner" as="category_banner" template="catalog/category/cat_img.phtml" />

In 3columns.phtml add this where you want the image to show

<div class="category-banner"
    
<?php echo $this->getChildHtml('category_banner'?>                
</div>

But this gives a server error on every page that isn’t a category page............... :(

Can I put this in the catalog.xml page?

 
Magento Community Magento Community
Magento Community
Magento Community
 
brunomarshall
Guru
 
Avatar
Total Posts:  367
Joined:  2009-08-04
 

Hi,
No need to struggle a lot just go to catalog /category /view .phtml there ant top you will find a if condition where they if ($_imgUrl = $_category->getImageUrl()) {} copy it and paste where ever you want if any error message occurs just extend the class to the page

 
Magento Community Magento Community
Magento Community
Magento Community
 
heather.ph
Jr. Member
 
Total Posts:  16
Joined:  2010-10-04
 

Thanks, I tried doing that but it still broke the other pages.

I decided to create a new template for each category that needs a banner on. Not the ideal solution! But it works anyway cheese

 
Magento Community Magento Community
Magento Community
Magento Community
 
lovey1
Jr. Member
 
Total Posts:  6
Joined:  2013-02-06
 

having the same problem ......
can\’t it be fixed using css or xml files .......

please help for the topic....

 
Magento Community Magento Community
Magento Community
Magento Community
 
lovey1
Jr. Member
 
Total Posts:  6
Joined:  2013-02-06
 

hey

i just found the solution for the problem .

u just need to test that if the page is category page or not in your column layout phtml file .
if your current page is category page only then it will show the banner otherwise not

<?php if (Mage::registry(\'current_category\')) { ?>

u just need to add this extra line.

on my 2columnsleft template i done this :

<?php if (Mage::registry(\'current_category\')) { ?>
<?php
$_helper = $this->helper(\'catalog/output\');
$_category_detail=Mage::registry(\'current_category\');?>
<div class=\"inner_banner\"><img src=\"<?php echo $_category_detail->getImageUrl(); ?>\"/>

</div>
<?php }?>

grin

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top