leeego Posted August 8, 2013 Share Posted August 8, 2013 i try to remove certain scripts i don't need in my shop (e.g. serialScroll, fancybox) from the controller files. for example, i made an override on ParentOrderController.php like this: <?php class ParentOrderController extends ParentOrderControllerCore { public function setMedia() { parent::setMedia(); if ($this->context->getMobileDevice() === false) // Adding CSS style sheet //$this->addCSS(_THEME_CSS_DIR_.'addresses.css'); // Adding JS files $this->addJS(_THEME_JS_DIR_.'tools.js'); if ((Configuration::get('PS_ORDER_PROCESS_TYPE') == 0 && Tools::getValue('step') == 1) || Configuration::get('PS_ORDER_PROCESS_TYPE') == 1) $this->addJS(_THEME_JS_DIR_.'order-address.js'); //$this->addJqueryPlugin('fancybox'); if ((int)(Configuration::get('PS_BLOCK_CART_AJAX')) || Configuration::get('PS_ORDER_PROCESS_TYPE') == 1) { $this->addJS(_THEME_JS_DIR_.'cart-summary.js'); $this->addJqueryPlugin('typewatch'); } } } so i simply commented the scripts/css i don't need (in this case fancybox and addresses.css). however, this does not work. the script is still included on the page. if i also comment out parent::setMedia() then fancybox gets removed, but not only fancybox, also global.css for example. what am i doing wrong? thanks for any help! Link to comment Share on other sites More sharing options...
tomerg3 Posted August 8, 2013 Share Posted August 8, 2013 parent::anything call the original function, which basically means you are adding to it, not replacing it. If you remove the parent:: then you are truly replacing it, and should keep everything that was in the original function, except the parts you want to disable. Link to comment Share on other sites More sharing options...
leeego Posted August 8, 2013 Author Share Posted August 8, 2013 (edited) I thought so too, but then why is global.css removed as soon as I remove the call to parent::setMedia()? If I change the following line from $this->addCSS(_THEME_CSS_DIR_.'addresses.css'); to $this->addCSS(_THEME_CSS_DIR_.'global.css'); it obviously gets included again. Do I have to override all controller files' setMedia functions when I don't use css files like addresses.css or product.css and replace them with global.css? Edited August 8, 2013 by leeego (see edit history) Link to comment Share on other sites More sharing options...
tomerg3 Posted August 9, 2013 Share Posted August 9, 2013 It's a bit like a chicken and egg. If you do not call parent::setMedia() then global.css will not be added (as the parent calls setMedia from FrontController). You should be able to replace parent::setMedia with FrontController::setMedia(), that would bypass the setmedia from parentOrderController, but would still call the setmedia that loads global.css (as well as other files). Link to comment Share on other sites More sharing options...
leeego Posted August 9, 2013 Author Share Posted August 9, 2013 Perfect, it worked. Thanks! Link to comment Share on other sites More sharing options...
vekia Posted August 9, 2013 Share Posted August 9, 2013 woohoo! great solution here im going to mark this topic as [solved] best regards Link to comment Share on other sites More sharing options...
Recommended Posts