Page 1 of 1

IF Then Display Text on Homepage Only

Posted: Sat Dec 20, 2008 5:22 pm
by Danielc1234
Hi all, new to php. I am trying to put a command in my header that will display some text only if it is the home page or "/" page.

<?php if($this->getRequest()->getRequestUri() == '/') { /* show it */ } ?>

This is what I have so far, but not working correctly. Can some one tell the full php code to use if the page is the home page do this <div class="vtop"><h1 align="center">DOG CAR SEATS | DOG CAR SEAT</h1></div> and if not the home page, do nothing at all?

Thanks in advance

Re: IF Then Display Text on Homepage Only

Posted: Sat Dec 20, 2008 5:44 pm
by GreenCore
Maybe this will help:

Code: Select all

<?php
    if ($_SERVER["REQUEST_URI"] === "/"){
            //main root website (also for subdomains)
            //Your Code
            echo '<div class="vtop"><h1 align="center">DOG CAR SEATS | DOG CAR SEAT</h1></div>';
    } else {
            //Your Code
    }
?>
Good luck!

Re: IF Then Display Text on Homepage Only

Posted: Sat Dec 20, 2008 6:02 pm
by Danielc1234
GreenCore, Thanks it worked great!!!!!