Jump to content

Different Include Problem


Zeradin

Recommended Posts

I did a search for this and saw a lot of people asking similar questions, but all the ones that were solved seemed to have no replies. I don't get it.

 

Anyway... real basic question:

 

in my main folder i have my header.php, footer.php, css file and a folder called content

in the content folder I have a template that has an include to ../header.php etc

 

is there a way to make the include look at the things it refers to relative to itself rather than relative to the page that includes it?

 

thanks guys

Link to comment
Share on other sites

for some reason I can't get it to work. I read in thephp manual that this sets the location of the include for the duration of the script so i'd put it in the header and footer... that didn't work... i also moved it to the template before the include calls. also, i messed around with making the path './', '../' '' '/'

 

here's the script i'm currently using, the only one that doesn't generate tons of errors. sorry i'm so slow

 

the template file has:

	<?php
	$page=array();
	$page['title'] = 'TEMPLATE';
	set_include_path('../');
	include('hypheader.php');
?>

and

                <?php
				set_include_path('../');
				include('../hypfooter.php');
			?>

 

the header and the footer don't have anything different in them right now. getting closer at least.

 

Link to comment
Share on other sites

Use $_SERVER['DOCUMENT_ROOT'] instead. set_include_path is not what you need. Eg:

include $_SERVER['DOCUMENT_ROOT'] . '/hypheader.php'

PHP will always include hypheader.php from the root of your website, no matter how far down the directory tree the include command is taking place.

Link to comment
Share on other sites

well.. that got it to load the header, but the header is still trying to load things from where the page is, not where the header is located.... basically i get a blank page aside from some stuff in the footer that randomly works. Why?

Link to comment
Share on other sites

<?php
define("SERVER_ROOT", $_SERVER['DOCUMENT_ROOT']);

include(SERVER_ROOT."/folder/blah/file.php");
?>

 

<?php
define("SERVER_ROOT", $_SERVER['DOCUMENT_ROOT']);

include(SERVER_ROOT."/thehyp/hypheader.php");
?>

 

still loads the header, but the header doesn't load any of the images.

Link to comment
Share on other sites

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $page['title']?></title>
<link href="cssface.css" rel="stylesheet" type="text/css" />
<link rel="shortcut icon" href="favicon.ico">
<!-- Fix IE. Hide from IE Mac \*/
* html ul li { float: left; }
* html ul li a { height: 1%; }
/* End */ -->
</head>

<body topmargin="0" text=#FFFFFF link=#00CCCC alink=#a70000>
<!-- menu  -->
            <div id="header">
            <img src="images/header.jpg" border="0" usemap="#Map" />
            <map name="Map" id="Map2">
              <area shape="rect" coords="774,94,847,119" href="contact.php" alt="click here to send us hate mail...or other such junk" />
              <area shape="rect" coords="699,96,756,118" href="links.php" alt="click here to view links to other sites" />
              <area shape="rect" coords="344,97,411,120" href="articles.php" alt="click here to read articles on various topics" />
              <area shape="rect" coords="110,100,158,119" href="index.php" alt="click to access news section" />
              <area shape="rect" coords="185,98,311,121" href="http://www.hypboard.com" alt="click here to access the message board" />
              <area shape="rect" coords="438,95,489,121" href="focus.php" alt="click here to read in-depth focus articles" />
              <area shape="rect" coords="519,96,591,120" href="reviews.php" alt="click here to read reviews" />
              <area shape="rect" coords="617,97,674,119" href="media.php" alt="click here to access media" />
            </map>
<map name="Map" id="Map">
  <area shape="rect" coords="699,96,756,118" href="links.php" alt="click here to access media" />
  <area shape="rect" coords="344,97,411,120" href="focus.php" alt="click here to read focus articles" />
  <area shape="rect" coords="110,100,158,119" href="index.php" alt="click to access news section" />
  <area shape="rect" coords="185,98,311,121" href="http://www.hypboard.com" alt="click here to access the message board" />
<area shape="rect" coords="440,94,491,120" href="focus.php" alt="click here to read focus articles" />
<area shape="rect" coords="519,96,591,120" href="reviews.php" alt="click here to read reviews" />
<area shape="rect" coords="617,97,674,119" href="media.php" alt="click here to access media" />
</map>
   	  
<!-- menu ends -->

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.