1

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.

3

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>
  • That explains "everything", about to do it in the code, I can't, we add that class in the admin section only. – Di36o Jun 10 '16 at 9:48
  • @Di36o I don't totally understand your comment. Do you need further help ? – Raphael at Digital Pianism Jun 10 '16 at 9:49
  • No, your answer explains what I was asking for, but i can't "vote up" your answer :( – Di36o Jun 10 '16 at 10:01
  • @Di36o no worries mark it as accepted when you can, not a big deal ;) – Raphael at Digital Pianism Jun 10 '16 at 10:03
1

Try this for admin, locate file

app\design\adminhtml\default\default\layout\local.xml

and add

<?xml version="1.0"?>
<layout>
    <default>
        <reference name="root">
          <action method="setBodyClass"><classname>camelCased</classname></action>
        </reference>
    </default>
</layout>
  • It won't work, my goal was add a camel cased class into frontend category page, using the "Custom layout update" field in the admin section. – Di36o Jun 10 '16 at 11:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.