Fix theme configuration section on Display preference and improve `isFrontendPage` function for Drupal CMS
While working on the Drupal web-forms, when we are using CiviCRM fields (like payment processors) on the Drupal webform pages, the CiviCRM current theme JS and CSS files were leaking (rendering) on the Drupal webform page. This was making the page styling more difficult as one has to first reset the leaking CSS and then style on top of them. Also, there were some bootstrap JS libraries (when Shoreditch is the CiviCRM) file which was loading on the page. So, if a developer wants to develop a bootstrap based Drupal 7 themes and try to style the CiviCRM components, the Shoreditch bootstrap JS files conflicts with Drupal 7 bootstrap theme JS files.
To fix this we had to find a way to stop CiviCRM to apply its theme assets. The best way of it is to find a way in CiviCRM which will contextually select/deselect a CiviCRM theme on Drupal CMS pages. And apparently, the CiviCRM core provides such a feature under the display preference page to select different Front-end and Back-end theme. Unfortunately, this feature was not for Drupal CMS and hence the issue.
For the Drupal CMS, the CiviCRM doesn't provide separate configurations for setting the frontend theme (FE) and the backend theme (BE). This is however present for other CMS integrations
The problem with this is that the Drupal User couldn't set the front end theme and the backend theme separately. So, to fix this we remove the extra if logic just for Drupal CMS which hides the configuration for the FE-theme and BE-theme and loads the configuration for drupal as well. This will print both the configuration fields.
Also, the CiviCRM theme CSS was leaking on drupal pages too which uses the CiviCRM fields (and in turn called
civicrm_initialise() function). This is because
$config->userSystem->isFrontEndPage() function is buggy for Drupal CMS as it return
false if the user opens a drupal public page. This is because
isFrontEndPage() function )doesn't take care of the corner case of page URLs which are not CiviCRM's one. As it only checks if the URLs is a CiviCRM public URL
$item = CRM_Core_Menu::get($path); // What if `$item` is empty? return !empty($item['is_public']);
$item is empty (that means it's a non-CiviCRM page) even then it returns
false because the logic is incomplete. It doesn't check if the
$item is empty.
This fix addresses both these issues.
- Click on Administration -> Customise data and screens -> Display preference.
- Go to