I want to remove default Drupal CSS files if it is a front page in Drupal 7 theme.

Following is the code (got from http://www.grahamgilchrist.com/blog/25) that I am trying to put in the template.php for barktik1 theme. How do I check if rendering page is a front page or not? Only $css variable is passed as an argument to the theme_css_alter() function while for other process functions $variables is passed from which it is easy to determine if it is a front page or not.

function bartik1_css_alter(&$css) { 

//do something to check if it is a front page
if ($is_front){
    //make a list of module css to remove 
    $css_to_remove = array(); 
    $css_to_remove[] = drupal_get_path('module','system').'/system.base.css'; 
    $css_to_remove[] = drupal_get_path('module','system').'/system.menus.css'; 

    // now we can remove the contribs from the array 
    foreach ($css_to_remove as $index => $css_file) { 



The function you're looking for is drupal_is_front_page().

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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