Jump to content

Know From Tpl File If Ccc Is Active For Css


Guest

Recommended Posts

Hi

 

I need to check in a .tpl file if CCC is active to know if I am going to include a specific css file or not.

 

Is there an existing way to know this from the presentation layer or would I have to add a new PHP function first? 

 

Thanks in advance for any suggestions

Link to comment
Share on other sites

Well think you should try to add specific css file in php so that one is also included when CCC is enabled.

So one way is to check, you could add this to displayHeader hook if you are making a module

if (Configuration::get('PS_CSS_THEME_CACHE')) {
     $this->context->controller->addCSS($this->_path.'specific.css');
}

You can use similar code in tpl directly but not good practice.

Link to comment
Share on other sites

Thanks for the reply.

 

I agree this is the correct approach. However in my theme I have 2 css files included in 2 different tpl files for legacy reasons. These are the ones I want to control if they are added or not and I want to change as little as possible so being able to add this extra check in the tpl file would be a very simple solution for now.

 

You say it is possible to do almost the same code from tpl, even if it is not best practice, how would it look like.

 

Thanks again for your help

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