Jump to content

Add CSS Custom


pippo67

Recommended Posts

Hello everybody,

I would need help adding a custom css file.

I have created this path in the css folder: themes /mytheme /css /modules / mystyle /style.css.

Which controller should I add the instruction below highlighted to change the left column block in the homepage?

 

$this->context->controller->addCSS($this->_path'view/css/style.css','all')

 

 

Thank you.

 

Bye

 

 

P.S. I use the prestashop version 1.6

Link to comment
Share on other sites

I do not have a custom module, but I'm working on default blockcategories.css. I would not like to edit the blockcategories.ccs file, but I created a cutsom css file in the path indicated in the first post. Thanks to your answer I hope to have you sorted it out like this:
First I put the line in red in the file below, then I added the link highlighted in blue.
 

Categorycontroller.php

 

public function setMedia()

{

        parent::setMedia();

 

        if (!$this->useMobileTheme()) {

            //TODO : check why cluetip css is include without js file

            $this->addCSS(array(

                _THEME_CSS_DIR_.'scenes.css'       => 'all',

                _THEME_CSS_DIR_.'category.css'     => 'all',

                _THEME_CSS_DIR_.'product_list.css' => 'all',

                               _THEME_CSS_DIR_.'custom.css' => 'all',

            ));

        }

 

Header.tpl

 

{if isset($css_files)}

     {foreach from=$css_files key=css_uri item=media}

          {if $css_uri == 'lteIE9'}

                <!--[if lte IE 9]>

                       {foreach from=$css_files[$css_uri] key=css_uriie9 item=mediaie9}

                         <link rel="stylesheet" href="{$css_uriie9|escape:'html':'UTF-8'}" type="text/css" media="{$mediaie9|escape:'html':'UTF-8'}" />                                                                                                                                                 

                             {/foreach}

                             <![endif]-->

                        {else}

                             <link rel="stylesheet" href="{$css_uri|escape:'html':'UTF-8'}" type="text/css" media="{$media|escape:'html':'UTF-8'}" />

                       

                           <link rel="stylesheet" href="{$css_dir}custom.css" type="text/css" media="{$media}" />

                        {/if}

             {/foreach}

 

I tried to make changes and work.

Is this the correct procedure?
 
 
Otherwise, following your answer, if I had a personal module, entering the blue line in the public function hookHeader () class, would the procedure be equally obscure?
 

File blockcategories.php

 

public function hookHeader()

{

 $this->context->controller>addJS(_THEME_JS_DIR_.'tools/treeManagement.js');

 $this->context->controller->addCSS(($this->_path).'blockcategories.css', 'all');

 $this->context->Controller->addCSS($this->_ path'style.css', 'all');

}

 

Bye.

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...