Try the Demo

Magento Forum

   
skinJs bug? 
 
iblastoff
Sr. Member
 
Total Posts:  252
Joined:  2007-08-31
 

what im trying to do: add a custom js file from a custom theme named ‘second_theme’

when adding this line:

<action method="addItem"><type>skinJs</type><name>test.js</name></action>

to page.xml, i get this returned in the html source:

<script type="text/javascript" src="http://magento.dev/skin/frontend/default/second_theme/js/test.js" ></script>
<link type="text/css" rel="stylesheet" href="http://magento.dev/skin/frontend/default/default/css/test.js" ></link>

why does it try and also add the test.js as css as well?

on closer inspection of app/code/core/Mage/Page/Block/Html/Head.php i see this:

switch ($item['type']{
     
case 'js':
          
$lines .= '<script type="text/javascript" src="'.Mage::getBaseUrl('js').$item['name'].'" '.$item['params'].'></script>';
     break;

     case 
'skinJs':
          
$lines .= '<script type="text/javascript" src="'.$this->getSkinUrl('js/'.$item['name']).'" '.$item['params'].'></script>';

     case 
'css':
          
$lines .= '<link type="text/css" rel="stylesheet" href="'.$this->getSkinUrl('css/'.$item['name']).'" '.$item['params'].'></link>';
     break;
}

shouldn’t there be a ‘break;’ for the skinJs case as well?

 Signature 

stevelam.ca | xpattern.net

 
Magento Community Magento Community
Magento Community
Magento Community
 
Moshe
Magento Team
 
Avatar
Total Posts:  1770
Joined:  2007-08-07
Los Angeles
 

great catch!

Edit Mage_Page_Block_Html_Head and add after line 96 “break;” before “case ‘css’:”

Thanks

 Signature 

- I would love to change the world, but they won’t give me the source code -

 
Magento Community Magento Community
Magento Community
Magento Community
 
Scott
Guru
 
Avatar
Total Posts:  333
Joined:  2007-08-31
Northwest Ohio
 

Tried using this skinJs type, and it’s still appending to the js packer:

<script type="text/javascript\" src="../index.php?c=auto&f=,prototype/prototype.js,prototype/validation.js,scriptaculous/builder.js,scriptaculous/effects.js,scriptaculous/dragdrop.js,scriptaculous/controls.js,scriptaculous/slider.js,varien/js.js,varien/form.js,varien/menu.js,mage/translate.js,mage/cookies.js,varien/product.js" ></script>

I thought this was the way to do it. Has something changed?

 Signature 

Need a Magento designer? I specialize in helping developers and shop owners create Magento themes designed with aesthetic bliss, crisp refreshing style, and usability-focused design. Check out Tealo, the first public Magento theme!

Your Magento Partner for Stunning Creative Work!

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top