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.

2 Answers 2

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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