Forum Moderators: coopster

Message Too Old, No Replies

Include same menu across different directories?

         

terrybarnes

12:09 am on Mar 1, 2009 (gmt 0)

10+ Year Member



I'm using SSI to include common elements on the pages, such as footer, header and menu. The one thing I'm really not sure of is how I can refer to the same menu from pages that reside at different levels on the site.

I.e. If I have the same menu included in:

index.php
/pages/page1.php
/pages/category/page2.php

and the menu.php include is located in an "includes" folder at root.

How will the menu be able to link correctly to the different pages without me adding physical root to each page i.e. www.mysite.com/pages/page1.php.

I'm very confused and I'm sure this is a very simple thing?

Any help would be very much appreciated.

blang

12:49 am on Mar 1, 2009 (gmt 0)

10+ Year Member



If you have a directory named "includes" at the top level, i.e web root, or even up above in your home directory, you should be able to alter your include_path directive to add this directory. You can do this either in each script, in an .htaccess file, or if you have access to it, the php.ini config file itself.

Once you've done this, you can include any script in that directory by name without worrying about where it is in the path. Just be mindful to give the included scripts unique names.

Take a look at the PHP manual page on 'how to change configuration settings [us2.php.net]'.