You are here:  » php include on homepage / index.php


php include on homepage / index.php

Submitted by Oisin on Sat, 2006-10-07 05:32 in

hi,

i want to insert a code or text that will be visible only on the index.

i would have to insert it on the /html/footer.php for proper layout.

thank you.

Submitted by support on Sat, 2006-10-07 08:33

Hi there,

The best thing to do in this situation would be to edit index.php directly, as the file in /html/footer.php is included on every page.

The index.php in the distribution is intended as a starting point anyway, so you are perfectly safe to modify it as much as you want.

Cheers!
David.

Submitted by Oisin on Sun, 2006-10-08 02:58

hi david,

i am thinking more like an IF statement,

if the file is index.php then print this.. something like that :)

i have an include that needs to be on the top right navigation bar but my given my existing template, that is not possible.

if this is not possible, its OK. :)

cheers,
oisin

Submitted by support on Sun, 2006-10-08 04:32

Sure, you can do that - you need to look at the $_SERVER["PHP_SELF"] variable (assuming that it is set on your system) and make your code - or another include - conditional based upon it, so you could add something like this to footer.php.

You can also create a new file called user_footer_before.php if you want to be able to re-install Price Tapestry without losing your changes...

if ($_SERVER["PHP_SELF"] == "index.php")
{
  // footer code for index page here
}

Cheers,
David.

Submitted by Oisin on Mon, 2006-10-09 09:48

hi david,

i tried this code but it doesnt seem to work.

<?php
if ($_SERVER["PHP_SELF"] == "../index.php")
{
 print 
"some text here";
}
?>

the code may be wrong, am no PHP wizard :)

Submitted by support on Mon, 2006-10-09 11:06

Hiya,

The thing to do is to print out the value of $_SERVER["PHP_SELF"] just to make sure exactly what you need to put in the test, for example:

<?php
print $_SERVER["PHP_SELF"];
?>

That should help...
Cheers,
David.