Magento – how to add class camelCased to body

layoutlayout-updatemagento-1.9

I was trying to add a camelCased class into the body tag, is there some way to do it? I'm using this:

<reference name="root">
  <action method="addBodyClass"><classname>camelCasedClass</classname></action>
</reference>

But it outputs:

<body class="catalog-category-view camelcasedclass">

Obviously i could change the class name, but it come from a third party lib and I don't wanna change it.

Best Answer

The problem is that the addBodyClass method automatically lower case the class:

public function addBodyClass($className)
{
    $className = preg_replace('#[^a-z0-9]+#', '-', strtolower($className));
    $this->setBodyClass($this->getBodyClass() . ' ' . $className);
    return $this;
}

To avoid that I reckon you should try to set the class directly:

<reference name="root">
  <action method="setBodyClass"><classname>camelCasedClass</classname></action>
</reference>
Related Topic