8

How do I make a simple front page check wich only shows a in my template when the user is on the front page of the drupal website?

I tried this but it ended up crashing:

<?php function drupal_is_front_page() {?> <h1>TEST</h1> <?php } ?>

Is this possible with a if instead of this function wich i found on the drupal website?

Thanks!

19

You should not declare a function in a Drupal template. Instead, you should just refer to that function:

<?php
if (drupal_is_front_page()) {
    ?><h1>Test</h1><?php
}
?>
  • 4
    Note that if your template is a derivative of page.tpl.php you already have the $is_front variable available – Clive Nov 11 '14 at 14:43
6

drupal_is_front_page() returns boolean value.

<?php if(drupal_is_front_page()): ?>
<h1>TEST</h1>
<?php endif; ?>

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.