3

I have the following in my template.php file, in my custom theme:

function shriver_css_alter(&$css) {
    unset($css[drupal_get_path('module','civicrm').'/css/civicrm.css']);
}

It doesn't work, though. I can disable other stylesheets this way, but not this one. I know I can disable this stylesheet in civicrm settings, but then it is disabled on the back end as well. I only want it to be disabled on the public pages. Since I use a different admin theme than my public one, I thought it made sense to disable it for my public theme only.

Can someone help me to get this to work? Or, if you know a different method, that would be good, too. Thank you.

2 Answers 2

3

This is the correct way to disable civicrm.css on the front end. Put this in the template.php file of your theme:

function shriver_css_alter(&$css) { unset($css['sites/all/modules/civicrm/css/civicrm.css']); }

Manually enter the path to the css. When I used drupal_get_path('module','civicrm'), it would output sites/all/modules/civicrm/drupal/css/civicrm.css. Not sure why it added 'drupal' to the path but that was the problem.

2
  • 1
    today I tried removing the civicrm css from the public page by adding function shriver_css_alter(&$css) { unset($css['sites/all/modules/civicrm/css/civicrm.css']); } to the themes template.php. Unfortunately it didn't work. The path to the css is the right one. Did something change during the last years? Commented Oct 7, 2020 at 13:41
  • Thanks for this, two notes: 1. This snippet hard-codes the file path location of the civicrm module, your location may be different (e.g. sites/default/modules/civicrm). 2. This function works equally well in a module (assuming the module's order is after civicrm).
    – Alan Dixon
    Commented Jan 29, 2021 at 17:02
1

You can also use the CiviCRM Theme module in Drupal Administration menus:

Drupal Modules Menu

Then, the following menu appears at the bottom of the Drupal Appearance menu:

Allow different themes to be used for front-facing CiviCRM pages

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.