php - Magento: how to use removeItem for js files added by extension programatically -
i have 3rd party extension adding js in via observer:
<?php class anowave_owl_model_observer extends mage_core_model_abstract { public function dispatch(varien_event_observer $observer) { if (mage::app()->getlayout()->getblock('owl') && mage::app()->getlayout()->getblock('owl')->getslider()) { $format = mage::app()->getlayout()->getblock('owl')->getformat(); if ($format instanceof anowave_owl_block_format) { $format->addcss()->addjs(); } } return $this; } }
where addjs defined in block class as:
public function addjs() { $script = 'js/jquery-1.11.0.min.js'; mage::app()->getlayout()->getblock('head')->additem('skin_js', $script); }
rather hack module, i'm trying remove loaded jquery via removeitem i.e.
<default> <reference name="head"> <action method="removeitem"> <type>skin_js</type> <name>js/jquery-1.11.0.min.js</name> </action> </reference> </default>
in local.xml. not work. (that js file still printed script tag in head). i.e.
<script type="text/javascript" src="http://mydomain.local/skin/frontend/base/default/js/jquery-1.11.0.min.js"></script>
i know syntax , pathing correct because can unload/remove other js files way in same folder (ones specified extension's layout xml instead). thought local.xml processed after other layout registration steps, guess not (?) don't think removeitem in layout option. i'd willing use
mage::app()->getlayout()->getblock('head')->removeitem('skin_js', $script);
in custom module, how know previous addjs() processing has finished executing?
any ideas or solutions appreciated!
if 3rd party extension in community
code pool can recreate same path of observer in local
code pool, magento check presence of class in local code pool first before other.
you have create path app/code/local/anowave/owl/model/
, place observer.php
file inside can safely modify class business logic without hacking original extension.
Comments
Post a Comment