php includes that correctly links href from wherever -


i'm trying include block of html hrefs. want able maintain 1 include file. current code is:

<?php include __dir__ . "/../../../includes/footer.php"; ?> 

this links fine except hrefs in footer.php file must prefaced ../../../ due location. means have create multiple footer files different hrefs.

to display folder structure(*indicates includes of same php file needed):

root ¦ +---includes ¦   ¦ ¦   +---footer.php ¦ ¦ +---main ¦   ¦ ¦   +---maps ¦       ¦ ¦       +---uk ¦           ¦ ¦           +---map.php* ¦ +---gallery.php* ¦ +---assets     ¦     +---icons         +         ¦         +---facebook_1.png 

finally worked out. mamp confusing things , had include php in link.

under mamp>conf>apache>httpd.conf changed documentroot "/applications/mamp/htdocs/radventures.co.uk" pointed root of site.

changeable document_root mamp configuration:

<?php   if ($_server['document_root'] == '/applications/mamp/htdocs/radventures.co.uk'){     $root = 'http_root';   }   else {     $root = 'document_root';   }   $link = "$_server[$root]"; ?>  

img link:

<img src="<?php echo ($link . "/assets/icons/facebook_1.png"); ?> 

include:

<?php include ($_server['document_root'] . "/includes/footer.php"); ?> 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -