Jump to content

Override .css in module version 1.7 doesn't work


dev99999

Recommended Posts

Hi,

I try to override blocktags.css from module blocktags, it is an .css file in the module's root directory.

I try to override this in /themes/mytheme/modules/blocktags/blocktags.css, but it doesnt work. Also tried in /css/blocktags.css etc. but no success. 

It works only in /themes/mytheme/assets/css/custom.css (changed css) ?

 

Edited by dev99999 (see edit history)
Link to comment
Share on other sites

I came here looking for this exact problem.

I assume the blocktags-module doesn't have a stylesheet in the [root]/modules/blocktags folder? (If it does, you should be able to override the css by using the same folder-structure in [root]/themes/your-theme/modules/blocktags - and place your css in the equivalent place.)

What I ended up doing was:
1. Register the new stylesheet (Basically tell Prestashop there is a new stylesheet available) in a php-file that extends the module-php, and place it in the [root]/override/modules/module-name folder (You probably have to create this folder). It should look something like this:

<?php
    class BlocktagsOverride extends Blocktags
    {
        public function hookHeader()
        {
            $this->context->controller->registerStylesheet('modules-blocktags', 'modules/'.$this->name.'/css/blocktags.css', ['media' => 'all', 'priority' => 150]);
        }
    }
?>


2. Create the new stylesheet and place it in [root]/themes/your-theme/modules/module-name/css (Or wherever you point when registering the stylesheet)

3. See the magic happen (if not; clear cache and pray)

 

I have to add that I'm not super confident about this solution, it works, but I'm not sure this is how it is intended. What I would like is to override the php in the theme-folder (and not the [root]/override folder), because if the theme is swapped out, the css in the theme is gone which makes the override unnecessary.


Guus

Edited by GuusMichielsen (see edit history)
Link to comment
Share on other sites

  • 2 weeks later...
  • 1 year later...

on presta 1.7.6 you can just add to your theme 
for example your module css is in here  [root]/modules/blocktags/views/css/[filename].css
module should have hookDisplayHeader

    public function hookDisplayHeader($params)
    {
        $this->context->controller->addCSS($this->_path . 'views/css/[filename].css', 'all');
 

themes css should be here  [root]/themes/your-theme/modules/blocktags/views/css/[filename].css  

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...