In Prestashop 1.7 function code to add a Javascript is little changed.
To add Javascript to a specific CMS Page in prestashop open
/override/controllers/front/CmsController.php
and add below code in it.public function setMedia() { parent::setMedia(); if ((int)Tools::getValue('id_cms') == 17) { $this->registerJavascript('theme-custom', '/assets/js/your-js.js', ['position' => 'bottom', 'priority' => 2000]); $this->registerStylesheet('theme-custom', '/assets/css/your-css.css', ['media' => 'all', 'priority' => 2000]); } }
above code will add Javascript and CSS to only CMS Page ID 17.
You can add JS in
/themes/your-custom-theme/assets/js/your-js.js
and CSS in /themes/your-custom-theme/assets/css/your-css.css
0 Comments