display/hide content only on the front page

Last modified: August 18, 2009 - 06:10

description

This snippet allows you to hide/display content on the front pageof a Drupal site.

usage

  1. Using a text editor like notepad.exe, kate, TextWrangler or an equivalent, copy and paste the snippet into your page.tpl.php or your custom page-type.tpl.php file.
  2. Remove the exclamation point (!) to show on the front page and use it to show everywhere except the front page.
  3. Change the div class names or the link prefix text to suit.

The following example snippet will insert an image called blocks-top.jpg on all pages EXCEPT the front page.

<?php if (!$is_front): ?>
  <div id="snapshot">
    <img src="http://www.example.com/images/blocks-top.jpg" /><br />
  </div>
<?php endif; ?>

 
 

Drupal is a registered trademark of Dries Buytaert.