I am trying to alter content of the system main block but only on the front page. I have added template_preprocess_block() in the template.php file, but is_front is FALSE even though I am on the front page of the site?

I use the Context module to control blocks, but the main block is the only one I have added using /admin/structure/block not Context.

Update I have also tested hook_block_view_MODULE_DELTA_alter() but is_front is not passed to this function.

Update Even though I disable the Main page content block front the Content region, I still see a node on the front page, publishing options set to published, promoted to front. Doing this on a fresh install locally.

Enabling the Main page content block and setting "All pages except those listed" to doesn't change anything - still looking at my node.

3 Answers 3


Use function drupal_is_front_page().


simplest and most straightforward solution: Create two versions of that block and from this textarea select where the block should be

enter image description here

then do the appropriate configuration.

  • yeah, that could be an option Aug 8, 2014 at 13:38
  • weird but remoning the main block from the content region has no effect. I still see content on the front page. Aug 11, 2014 at 10:17

you could try something like this, even if the conditions aren't exactly the same:

    // works with paths like 'home' too, as well as 'node/2'
    $is_front_page = ($_GET['q'] == variable_get('site_frontpage', 'node') || drupal_get_path_alias(current_path()) == variable_get('site_frontpage', 'node'));

borrowed from here

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.