Forum Moderators: coopster

Message Too Old, No Replies

php include problem with menu bar

php include menu problem

         

Jako

3:20 pm on Jan 4, 2009 (gmt 0)

10+ Year Member



Hi there
Can someome please put me out of my misery.

I have only recently found the need for using php includes and I thought I was all sorted .... until now.

I have been using the following code to include my menu bar

<? include $HTTP_SERVER_VARS["DOCUMENT_ROOT"] . '/includes/menu.php'; ?>

Everything was working OK until I needed to add another level of directory. ie. I have pages in my root directory (index, contact etc) and then I have directories containing other pages. This was still working OK providing I didn't update links when I made a new page.

Now I have the need for another level of directory ie, attractions/walks.

The includes for header and footer work just fine at this level, however, the menu include doesn't work. It shows, but the links are wrong. Instead of looking back to the root dir for the includes folder, it looks back as attractions/sightseeing or attractions/accommodation, instead of just "sightseeing" or "accommodation"

I have used a 1st level template to create the pages and have tried daving the pages with and without updating links and this hasn't made any difference.

Could someone please help me.

Thanks so much

Di

PokeTech

5:07 pm on Jan 4, 2009 (gmt 0)

10+ Year Member



Try this:

<?php
$root = ""; //Where the main directory is
include $root . '/includes/menu.php';
?>

instead of using $HTTP_SERVER_VARS["DOCUMENT_ROOT"] just type it in yourself.

Jako

3:48 am on Jan 5, 2009 (gmt 0)

10+ Year Member



Hi there, thanks for your response, however, I need a little more help. I really don't understand php at all. I am not a programmer – I just have my own website.

My path to home is /home/discover/public_html/includes/menu.php . Can you please show me how it should be written into the code.

Thanks so much

Cheers

Di

Jako

3:51 am on Jan 5, 2009 (gmt 0)

10+ Year Member



Hi

I just thought that I woould mention that I have also tried
<?php include('/home/discover/public_html/includes/menu.php');?>

Again, this works fine on the header and footer includes, but not the menu.

Thanks