Question

In my magento store I've a basic category like: http://demo.magentocommerce.com/electronics/cellphones. I'm using the template 2columns-left.phtml.

Now I want (in the full width, BETWEEN the menu and the productlist) the category information (the picture and the description), with a 100% width.

In my template 2columns-left.phtml I've created this row:

<?php echo $this->getChildHtml('category_info') ?>

But how can I get the category description and photo here?

I suppose I need a Custom Layout Update in my category, like:

<block type="??" name="categpry_page_info" as="topCategoriInfo"
                   template="page/category_info.phtml"/>

But how can I do it? And how can I receive the category description and photo in my category_info.phtml template?

Or, maybe, there's an other way to get this info in my category page?

Was it helpful?

Solution

i have put magento block template class Mage_Catalog_Category_View.

Create local.xml under app/design/frontend/yourpackage/yourtemplate/layout/local.xml and

<?xml version="1.0"?>
<layout version="0.1.0">
<catalog_category_default>
      <reference name="content">
        <block type="catalog/category_view" name="categpry_page_info" as="topCategoriInfo"
                           template="page/category_info.phtml" before="category.products"/>
    </reference>
     </catalog_category_default>
     <catalog_category_layered>
       <reference name="content">
        <block type="core/template" name="categpry_page_info" as="topCategoriInfo"
                           template="page/category_info.phtml" before="category.products"/>
     </reference>
     </catalog_category_layered>
     </layout>

code of category_info.phtml is

  <?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');
    }
?>
<div class="page-title category-title">
    <?php if($this->IsRssCatalogEnable() && $this->IsTopCategory()): ?>
        <a href="<?php echo $this->getRssLink() ?>" class="link-rss"><?php echo $this->__('Subscribe to RSS Feed') ?></a>
    <?php endif; ?>
    <h1><?php echo $_helper->categoryAttribute($_category, $_category->getName(), 'name') ?></h1>
</div>

<?php if($_imgUrl): ?>
    <?php echo $_imgHtml ?>
<?php endif; ?>

<?php if($_description=$this->getCurrentCategory()->getDescription()): ?>
    <div class="category-description std">
        <?php echo $_helper->categoryAttribute($_category, $_description, 'description') ?>
    </div>
    <?php endif; ?

For getting image and description of category,need to upload category images and description

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top