Trying to add CSS to certain pages using a custom module in 7.x

05/07/2018


I tried following the instructions here: How to override some admin theme CSS rules? and have spent a lot of time and energy googling and iterating this, so I’m turning to the stack exchange community for help.

What I’m trying to do is make some text fields larger when a user tries to edit a page. I’m attempting to do this by writing a custom module that checks if the page’s url contains the string edit, and if so, enabling the custom css. The version is drupal 7, and I am working with Pantheon. So far, my module looks like this:

<?php

function admincss_preprocess_html(&$variables) {

$url_string = $_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];

if (strpos($url_string, 'edit') !== FALSE) {

  // reference your current admin theme
    $theme_path = drupal_get_path('theme', 'seven');

  // reference your own stylesheet
    drupal_add_css('sites/all/modules/admincss/css/admincss.css', array('weight' => CSS_THEME));
}

Why isn’t my module being used by edit pages? And what, specifically, is the $variables variable referencing?
Thank you in advance!

قالب وردپرس