Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-5241

Custom CSS Resource URL not added by drupal module

    Details

    • Type: Patch
    • Status: Done/Fixed
    • Priority: Minor
    • Resolution: Fixed/Completed
    • Affects Version/s: 3.0.1
    • Fix Version/s: None
    • Labels:
      None

      Description

      The custom css resource URL seems to no longer be working in drupal. It definitely did work in v 2.2.6 (and possibly later), and the fix here is ported from that version.
      Setting a custom css url in 'Administer->Global Settings->Resource urls->Custom CiviCRM CSS URL, should replace the main civicrm.css file in the HTML template. In v3.0.1 entering a value in this field appears to remove the main civicrm.css file from the HTML source, but not replace it with the new custom url entered in the admin page.

      I did a bit of digging and it seems to me the problem is in the civicrm drupal module (civicrm/drupal/civicrm.module), in the 'civicrm_html_head()' function.

      Code:

      if ( isset( $config->customCSSURL ) && ! empty( $config->customCSSURL ) ) {
      $head = "<style type=\"text/css\">@import url({$config->customCSSURL});</style>\n";
      } else

      { drupal_add_css(drupal_get_path('module', 'civicrm') . '/../css/civicrm.css'); }

      Here, the first part of the if statement adds the custom URL to the page head if one is set. This seems to work ok as I did some debug output checks on this value. The problem comes later in the function on line 60 here:

      Code:

      if ( $includeCommon )

      { $template =& CRM_Core_Smarty::singleton( ); $head = $template->fetch( 'CRM/common/jquery.tpl' ); }

      where the head value is again reset to the value of the jquery template, thus wiping out the earlier HTML which adds the css file. My fix was simple, to change the '$head =' to '$head .=', in the same way it was done in earlier version of civicrm:

      Code:

      if ( $includeCommon )

      { $template =& CRM_Core_Smarty::singleton( ); $head .= $template->fetch( 'CRM/common/jquery.tpl' ); }

      Is this intentional or a bug? Any chance it could get into the next release?

        Attachments

          Activity

            People

            • Assignee:
              kiran.jagtap Kiran Jagtap
              Reporter:
              grahamgilchrist Graham Gilchrist
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: