2

I'm using an extension that adds a class name vnecoms-cp to the body of adminhtml pages. This is then used to style the pages using css.

My problem is, this affects 1 specific page in a negative way. I would like a solution to remove the style from this specific page only. I believe the solution is to find a way to remove the vnecoms-cp class from the body tag of the page i want to remove the style from, so the style cannot be applied to that page at all.

here the code that is used to add the class to the body

<reference name="root">
        <action method="addBodyClass" ifconfig="vadmin/config/enabled"><className>vnecoms-cp</className></action>
    </reference>

enter image description here

as you can see it adds this to each pages body class.

i want to remove it from .../admin/inbox/index/...

Any help will be greatly appreciated!

5

If you're comfortable writing code and creating a new Module, follow these instructions to overwrite Mage_Adminhtml_Block_Page class. In your new custom class, add the following method:

/**
 * Remove CSS class from page body tag
 *
 * @param string $className
 * @return Mage_Adminhtml_Block_Page
 */
public function removeBodyClass($className)
{
    $className = preg_replace('#[^a-z0-9]+#', '-', strtolower($className));

    $existingClassNames = explode(' ', $this->getBodyClass());
    if ($i = array_search($className, $existingClassNames)) {
        unset($existingClassNames[$i]);
        $this->setBodyClass(implode(' ', $existingClassNames));
    }

    return $this;
}

From there, you can then add this to your Layout XML:

<reference name="root">
        <action method="removeBodyClass"><className>vnecoms-cp</className></action>
</reference>

Good luck!

  • good one if we want to go on with a module approach. so +1 – Rajeev K Tomy Aug 18 '15 at 5:12
2

There is no way to remove that class name from the body tag. An alternative solution that exist here is add another body class to the body tag and then define css rules for that class so that it will effectively remove all css rules that is applying by vnecoms-cp class.

Try this.

File: app/design/adminhtml/default/default/layout/local.xml

<layout>
    <!-- action handle: not sure about this. -->
    <adminhtml_inbox_index>
        <reference name="root">
            <action method="addBodyClass"><className>custom-class</className></action>
        </reference>

        <!-- this part will not be necessary, if you're using some custom css file -->
        <reference name="head">
            <action method="addItem"><type>skin_css</type><name>css/adminhtml/custom.css</name></action>
        </reference>
    </adminhtml_inbox_index>
</layout>

Now create css file and redefine css rule as your wish

File : skin/adminhtml/default/default/css/custom.css

.custom-class {
   //overwriting css rules
}

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.