Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jun 2007
    Location
    Canada
    Posts
    49
    Thanks
    1
    Thanked 1 Time in 1 Post

    Handling varied paths

    I want to organize my code into sections contained in their own sub-directories. There are a few files in the app root such as an index, login and logout scripts but the rest are in their own directories.

    app
    ... template
    ... ... images
    ... includes
    ... module1

    My header file within the template directory will create the HTML head including the call for the CSS. The problem I am having is depending on what script (and where) that I include the header.inc.php - I have problems making sure the CSS and images are included.

    How do you do this? Make sure that no matter where I call the header from it always includes the CSS and stuff correctly? I saw a post from November that touched on setting PHP's INI temporarily to include other paths. Is this how I have to do this?

    Thanks
    Of all the things I've lost in my life time, my mind is the one I miss the most!

  • #2
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by Nightchild View Post
    My header file within the template directory will create the HTML head including the call for the CSS. The problem I am having is depending on what script (and where) that I include the header.inc.php - I have problems making sure the CSS and images are included.

    How do you do this? Make sure that no matter where I call the header from it always includes the CSS and stuff correctly? I saw a post from November that touched on setting PHP's INI temporarily to include other paths. Is this how I have to do this?

    Thanks
    you can use $_SERVER['PHP_SELF'] to find the the file path relative to the document root of the server, and you allready know the path of the image or css directory. With this two elements you can compute, using realpath for example, the relative path you must use in your html element.

    take a look to "alban dot lopez+php dot net at gmail dot com" post:

    http://www.php.net/manual/en/function.realpath.php

    about computing the shortest relative path between two folders.

    best regards
    Last edited by oesxyl; 01-21-2008 at 04:39 AM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •