• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PHP Includes within Directories

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


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.

[eluser]Sean Murphy[/eluser]
Why not use something like

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

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

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.