Including Magento's "prototype/windows/themes/magento.css" Across Versions

2.1k views Asked by At

I've got an Magento admin console extension that enables a model window across the entire Magento admin console. In Magento 1.7, I can include the factory default CSS file with the following

$layout->getBlock('head')->addCss('lib/prototype/windows/themes/magento.css');    

However, in Magento 1.6, this file isn't in the skin folder, it's in the 'js_css' folder, and I need to use this

$layout->getBlock('head')->addItem('js_css', 'prototype/windows/themes/magento.css')

Is there an elegant, straight forward way for me to ensure this file is properly included across all versions of Magento without resorting to version sniffing and without resorting to making my own copy of the file.

3

There are 3 answers

1
beeplogic On

I don't know if this suggestion is any better but you could check where the file exist and let that determine which method to call.

0
Alana Storm On

I went this this for the time being — leaving the question open in the hopes something better comes along.

        //would fail if Magento lives in a sub-folder named base
        $skin_url = $design->getSkinUrl('lib/prototype/windows/themes/magento.css');
        $parts = explode('/',$skin_url);
        if(in_array('base', $parts))
        {
            $head->addItem('js_css', 'prototype/windows/themes/magento.css');
        }
        else
        {
            $head->addCss('lib/prototype/windows/themes/magento.css');    
        }
2
barbazul On

Probably the safest way would be to distribute your own version of the file with your package.

  • You will have absolute certainty of where the file resides after package installation
  • No unnecessary FS hits
  • No dependency on the version provided by Magento (of course this can backfire, as always)