I want to add a picture on top of category name in frontend. I tried creating a custom field for the category and adding a picture that way. I can see the custom field from admin, but I can't see anything I type in the custom textarea on my frontend category name. I tried flushing cache and reindexing data. I also tried adding in app/design/frontend/package/theme/template/catalog/category/view.phtml this code:
<?php if($_customAttribute = $this->getCurrentCategory()->getCustomAttribute()): ?>
<?php echo $_helper->categoryAttribute($_category, $_customAttribute, 'custom_attribute') ?>
<?php endif; ?>
But when i added it all my products disappeared and I still coundn't see changes to my category name.
Atwix_CustomCategoryAttribute.xml
<?xml version="1.0"?>
<config>
<modules>
<Atwix_CustomCategoryAttribute>
<active>true</active>
<codePool>local</codePool>
</Atwix_CustomCategoryAttribute>
</modules>
</config>
config.xml
<?xml version="1.0"?>
<config>
<modules>
<Atwix_CustomCategoryAttribute>
<version>0.0.1</version>
</Atwix_CustomCategoryAttribute>
</modules>
<global>
<resources>
<add_category_attribute>
<setup>
<module>Atwix_CustomCategoryAttribute</module>
<class>Mage_Catalog_Model_Resource_Setup</class>
</setup>
<connection>
<use>core_setup</use>
</connection>
</add_category_attribute>
<add_category_attribute_write>
<connection>
<use>core_write</use>
</connection>
</add_category_attribute_write>
<add_category_attribute_read>
<connection>
<use>core_read</use>
</connection>
</add_category_attribute_read>
</resources>
</global>
</config>
mysql4-install-0.0.1.php
<?php
$this->startSetup();
$this->addAttribute(Mage_Catalog_Model_Category::ENTITY, 'custom_attribute', array(
'group' => 'General Information',
'input' => 'textarea',
'type' => 'text',
'label' => 'Custom attribute',
'backend' => '',
'visible' => true,
'required' => false,
'visible_on_front' => true,
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
));
$this->endSetup();
Best Answer
It does not seem that programming is necessary to add an image above the items in a category. Here is a simple solution that may meet your requirements.
Here is the navigation:
That's it you are done. Maybe clear the cache if you change does not appear immediately.
Magento is very versatile out of the box with lots of built-in features.