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
IF Then Display Text on Homepage Only
Moderator: General Moderators
-
Danielc1234
- Forum Newbie
- Posts: 18
- Joined: Tue Jul 29, 2008 11:55 am
Re: IF Then Display Text on Homepage Only
Maybe this will help:
Good luck!
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
}
?>-
Danielc1234
- Forum Newbie
- Posts: 18
- Joined: Tue Jul 29, 2008 11:55 am
Re: IF Then Display Text on Homepage Only
GreenCore, Thanks it worked great!!!!!