How do I force code within the node.tpl.php to only appear on full pages, and not on the frontpage ?

I am making modifications to my phptemplate , node.tpl.php but I don't want these modifications too appear on the frontpage.

Appatently the homepage also uses node.tpl.php.



I think you can use a thing called is_front you can use...or more to the point "if this isn't the front this"..

if (!$is_front):



Hope that helps..is_front definitely works with page.tpl.php...and assume it will work with node.tpl.php as well.


if ($page == 0):

This works for node displays, taxonomy displays, any multi-node display. Not sure if the is_front query would do the same.

Conversely, you also can do:

if ($page != 0):


_____ ____ ___ __ _ _
Laura Scott :: design » blog » tweet

yep. good point Laura..that is probably better to use instead of the is_front..


It worked... ! :)

Thanks to Laura and Dublin

Wholesale DIrectory
Business Letters
Football News - I love China - Chinese Tourism and Business - Business 2 Business Directory

I realised this the hard way :-)

A theme developer should almost always use if($page==0) instead of if($is_front).

$is_front is set strictly for the front page. If you click on a taxonomy term then the resulting page (which looks like the frontpage but has only those nodes that are classified under that specific taxonomy term) does NOT have $is_front set.

Thanks everybody.

My Drupal-powered Blog: ThoughtfulChaos

My Drupal-powered Blog: Varun To Earth, Come in Earth!

I never have $is_front set, neither with the front page. I understand that front page can be any page especified in the main settings form. Have this been changed with v.4.6.6?

Robert Garrigos

Robert Garrigos
Professional site:
Personal site:
Catalan Drupal Users Group:

A good use for $is_front would be to hide the breadcrumbs. I'm doing that with a theme, so the padding and stuff isn't generated for the front page:

  <?php if (!$is_front && $breadcrumb != ""): ?>
    <?php print $breadcrumb ?>
  <?php endif; ?>

If you don't do that, it puts "", or something like that on 'node'.

-- | Churchofchristnet

On my Drupal 4.7.2 site $page is never set, regardless of if page is the homepage or not :(
I have one template for the homepage and another for the rest of the site. works fine with $is_front , but (defined as such in settings) does not. Bug?

I found the solution that may be not perfect, buy works fine for me

if ($is_front || variable_get('site_frontpage', 'node')==$_REQUEST["q"]) {
    //put your homepage related stuff here


I'm not sure $is_front still works.

For me I had to replace $is_front with the test $_REQUEST["q"]=="" (which should evaluate to true on the main page

So this code might display breadcrumb on all page but the home page (ie or

<?php if (!$_REQUEST["q"]=="" && !(variable_get('site_frontpage', 'node')==$_REQUEST["q"])) print $breadcrumb; ?>

Chris D.
Tech. articles with a WAMP+IIS+Drupal focus
Take a break: Guide to France

I have Drupal 4.7.2 and $is_front seems to be never set

I use

if (drupal_is_front_page()) { /*What you wont*/ }

This is a BugMeNot account.

I had the same problem, so I used this. It works now.

On my drupal 4.7 site, page is always set to 0, even on full-node views. how is that possible?

I'm noticing this too. $page never seems to be set. I'm on 4.7.3

Anyone know anything about this?

I'm having this same problem. Using 4.7.3 In node.tpl.php

if ($page == 0) {
works fine to make the distinction, but it doesn't work in page.tpl.php

I don't know why this is, but now I can't distinguish between these page types within the page template, which is kinda important.

Anyone know of a fix or alternative?


Michael Thorne


Now how do I check if I am browsing a taxonomy ?

Marcel - I love China - Chinese Tourism and Business - Business 2 Business Directory

I use the following test to see if I am browsing taxonomy

if ( arg(0) == 'taxonomy' && arg(1) == 'term' ) {
  // Browsing taxonomy pages

if ( arg(0) != 'taxonomy' && arg(1) != 'term' && !is_numeric(arg(1))) {
// browsing front page
return FALSE;

It's more than just the front page...

Chic Velvet

$is_front = use this for template, like page.tpl.php

drupal_is_front_page() = use this in block, node or other

i'm using this statement in page.tpl.php

i would like the front page to display flash
i would like the node 24 to display a single .png file
and i would like all other pages to display the javascript

<?php if ( $is_front ) : ?>
    <!-- param tags as necessary for your .swf -->
    <embed align="left" width="810" height="200" src="" allowscriptaccess="always"></embed><br><hr color="#cccccc">
<?php else if ($page == node/24) : ?>
<img src="">
<?php else ($page == 0) : ?>
<script LANGUAGE="JavaScript" TYPE="text/javascript">
// -->
<?php endif; ?>

the front page and node 24 work perfectly. however, all other pages do not. they display the single .png file as well and not the javascript. i'm thinking

<?php else ($page == 0) : ?>

is not working. any ideas/suggestions?


[Added <code> and </code> tags: nevets]

Two things I see

1) There is no default "$page" in page.tpl.php, you could replace else if ($page == node/24)> with else if ( $node->nid == 24 ).

2) else ($page == 0) should just be else

(Side note, in $page == node/24, node/24 needs to be in quotes, ie 'node/24')