llohoz Posted March 4, 2019 Posted March 4, 2019 (edited) Bonjour à tous, J'essaie de faire fonctionner custom.js (et éventuellement theme.js) quand le magasin est en mode maintenance. J'ai réussi avec custom.css mais les scripts javascript ne veulent pas se charger... Pour ce faire, j'ai édité le fichier /shop/classes/controller/FrontControler.php comme ceci: /** * Displays maintenance page if shop is closed. */ protected function displayMaintenancePage() { if ($this->maintenance == true || !(int) Configuration::get('PS_SHOP_ENABLE')) { $this->maintenance = true; if (!in_array(Tools::getRemoteAddr(), explode(',', Configuration::get('PS_MAINTENANCE_IP')))) { header('HTTP/1.1 503 Service Unavailable'); header('Retry-After: 3600'); $this->registerStylesheet('theme-main', '/assets/css/theme.css', ['media' => 'all', 'priority' => 50]); $this->registerStylesheet('theme-error', '/assets/css/error.css', ['media' => 'all', 'priority' => 1000]); $this->registerStylesheet('theme-custom', '/assets/css/custom.css', ['media' => 'all', 'priority' => 2000]); $this->registerJavascript('corejs', '/themes/core.js', ['position' => 'bottom', 'priority' => 0]); $this->registerJavascript('theme-main', '/assets/js/theme.js', ['position' => 'bottom', 'priority' => 50]); $this->registerJavascript('theme-custom', '/assets/js/custom.js', ['position' => 'bottom', 'priority' => 1000]); $this->context->smarty->assign(array( 'shop' => $this->getTemplateVarShop(), 'HOOK_MAINTENANCE' => Hook::exec('displayMaintenance', array()), 'maintenance_text' => Configuration::get('PS_MAINTENANCE_TEXT', (int) $this->context->language->id), 'stylesheets' => $this->getStylesheets(), 'javascript' => $this->getJavascript(), 'js_custom_vars' => Media::getJsDef(), 'notifications' => $this->prepareNotifications(), )); $this->smartyOutputContent('errors/maintenance.tpl'); exit; } } } Malheureusement rien ne se passe... Avez-vous une idée ? Merci Edited March 4, 2019 by llohoz (see edit history) Share this post Link to post Share on other sites More sharing options...
Jgoss Posted November 7, 2019 Posted November 7, 2019 Hello, Même souci ici. Puis-je savoir comment vous vous en êtes sorti, svp ? Merci Share this post Link to post Share on other sites More sharing options...
llohoz Posted November 7, 2019 Posted November 7, 2019 Salut, Ça fait quelques mois mais voici les modifications que j'ai faites, avec $assets /** * Displays maintenance page if shop is closed. */ protected function displayMaintenancePage() { if ($this->maintenance == true || !(int) Configuration::get('PS_SHOP_ENABLE')) { $this->maintenance = true; if (!in_array(Tools::getRemoteAddr(), explode(',', Configuration::get('PS_MAINTENANCE_IP')))) { header('HTTP/1.1 503 Service Unavailable'); header('Retry-After: 3600'); $this->registerStylesheet('theme-main', '/assets/css/theme.css', ['media' => 'all', 'priority' => 50]); $this->registerStylesheet('theme-error', '/assets/css/error.css', ['media' => 'all', 'priority' => 1000]); $this->registerStylesheet('theme-custom', '/assets/css/custom-error.css', ['media' => 'all', 'priority' => 2000]); $assets = $this->context->shop->theme->getPageSpecificAssets($this->php_self); if (!empty($assets)) { foreach ($assets['css'] as $css) { $this->registerStylesheet($css['id'], $css['path'], $css); } foreach ($assets['js'] as $js) { $this->registerJavascript($js['id'], $js['path'], $js); } } $this->context->smarty->assign(array( 'shop' => $this->getTemplateVarShop(), 'HOOK_MAINTENANCE' => Hook::exec('displayMaintenance', array()), 'maintenance_text' => Configuration::get('PS_MAINTENANCE_TEXT', (int) $this->context->language->id), 'stylesheets' => $this->getStylesheets(), 'javascript' => $this->getJavascript(), 'js_custom_vars' => Media::getJsDef(), 'notifications' => $this->prepareNotifications(), )); $this->smartyOutputContent('errors/maintenance.tpl'); exit; } } } Je ne me rappelle plus la source... En espérant vous avoir aidé ! Share this post Link to post Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now