Welcome Guest, Not a member yet? Register   Sign In
PHP Includes within Directories
#1

[eluser]pgsjoe[/eluser]
I never truly know whether or not I'm doing things the correct way. This is more of a general PHP question, but with regard to CI. I use a head.php and a foot.php on the majority of my files. I feed in other variables as well such as mainNav.php, etc. I've run into a real problem when I begin to put items into directories. For instance, if I have

/head.php
/index.php
/foot.php
/about/bios.php

How would I want to include the head and foot file within there? I've tried using a config file so that my includes are as follows:

include ($root . 'head.php'); But what should root be? I tried using $_SERVER['DOCUMENT_ROOT'] but that brings me back too far and it's like /home/web1/www/domain.com

With relation to CI, I have CI in my root directory. In there, I want to reference the same head elements, but each item is buried 2 or three deep. Do I really have to resort to ../././ for each include? Thanks in advance.
#2

[eluser]Sean Murphy[/eluser]
Why not use something like
Code:
$this->load->view('includes/header.php');

That way all the paths are relative to the views directory.
#3

[eluser]pgsjoe[/eluser]
I'm not fully using CI to handle the entire site yet, just bits and pieces right now.




Theme © iAndrew 2016 - Forum software by © MyBB