SitePoint Sponsor

User Tag List

Results 1 to 9 of 9

Thread: Template links

  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2003
    Location
    France
    Posts
    50
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Template links

    I have just one header with the same links for my site, but one section of the site is in it's own folder, so for that header I have to change the links to point to ../../images/ for example instead of just images/. What's a good way of solving this so I can have links in the header that will work no matter where the html page is?

  2. #2

    Join Date
    Oct 2003
    Location
    €uroLand
    Posts
    1,340
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use absolute paths?
    HTML Code:
    <img src="/images/.....">

  3. #3
    SitePoint Enthusiast
    Join Date
    Nov 2003
    Location
    France
    Posts
    50
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh right! Feel embarrassed it's so easy, I got carried away from reading all these posts about templates

  4. #4
    SitePoint Enthusiast
    Join Date
    Nov 2003
    Location
    France
    Posts
    50
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, an extension of this, is there a way to specify the links so when I'm testing them on my computer and then uploading to the server, I don't have to change any links? Something with document root?

  5. #5

    Join Date
    Oct 2003
    Location
    €uroLand
    Posts
    1,340
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Specify what exactly?

  6. #6
    SitePoint Enthusiast
    Join Date
    Nov 2003
    Location
    France
    Posts
    50
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well for example if I have some include files, that are outside of the public_html folder, how can I specify the links to those include files so that they work on both my computer and the server where I upload them? Would getenv('DOCUMENT_ROOT') work? But does that work for files that are outside the public folder?

  7. #7

    Join Date
    Oct 2003
    Location
    €uroLand
    Posts
    1,340
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why would you have files outside of public_html?

  8. #8
    SitePoint Enthusiast
    Join Date
    Nov 2003
    Location
    France
    Posts
    50
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just thought it would be safer, for example including a file that contains functions that connect to the database.

  9. #9

    Join Date
    Oct 2003
    Location
    €uroLand
    Posts
    1,340
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    True to some extent. You could "solve" this with a wrapper file or double include.

    Put a file which includes the file in question into the root directory and then include this file instead of the original file. The only difference between your local copy and the remote copy would be that this wrapper file takes the original file from different locations (depending whether local or remote) and will not be replaced when you upload your files.

    Just a workaround of course.


Bookmarks

Posting Permissions

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