Tuesday, June 29, 2010

Magento - Ampersand in Category name not showing properly

Quite a few Categories added to a test install of Magento shopping cart had the ampersand character in the name. The Category page was displaying the ampersand in the name as & a m p ; which is the special HTML entity for the ampersand character.

I fiddled around with the settings in the back-end admin but there was no solution like the one I had stumbled upon for a similar problem in Product names here.

After a lot of fiddling, it turned out that this was happening because the category view PHP file for the theme I was using had compatibility issues with the instaleld cart version. The solution was to modify the app/design/frontend/MYTHEME/template/catalog/category/view.phtml as follows:

Search for occurrences the line:
<h2><?php echo $_helper->categoryAttribute($_category, $this->htmlEscape($_category->getName()), 'name') ?></h2> 

Replace with this line:
<h2><?php echo $_helper->categoryAttribute($_category, $_category->getName(), 'name') ?></h2> 


Explanation:
We are changing the theme view code to not translate any characters in the name that may have a HTML Special Entity representation. So these will remain as they are and you will not see the names going haywire!

Note that this may need to be done in a different file depending on which of the files are causing this problem. The errant file could be an incompatible older version of a plug-in as well.

1 comment:

Darshan said...

Apparently, this is has been fixed now in the latest version of Magento - 1.4.1.1

LinkWithin

Related Posts Plugin for WordPress, Blogger...