Member
Member
PrimeMover   13-12-2014, 00:03
#1

I'm trying to integrate the style of my gallery into the rest of the site I'm working on. In the rest of the style I use server-side includes to piece together the site (so I can remotely change the navigation bar, etc, all at once). I've changed these from HTML style includes to PHP includes, for instance:

``

but they're giving me errors. It can't seem to find the files:

Quote:Warning: include(/includes/head.html): failed to open stream: No such file or directory in /home/*****/public_html/gallery/themes/norrisbowers/index.php on line 14
Any clues what could be going on?

Member
Member
gjr   13-12-2014, 02:25
#2

You relative include path is wrong, hence the can't find the file. You need to back out of Zenphoto to your root files of your main site. Just guessing on your structure but try:

`

`

Member
Member
PrimeMover   14-12-2014, 21:39
#3

Aha! It seems PHP doesn't process relative links the same way html or css does. Typically a leading "/" sends the file system back to the root, but not with php. Using the $_SERVER["DOCUMENT_ROOT"] constant solves this problem.

Member
Member
gjr   14-12-2014, 22:37
#4

A relative link is relative in css, html, or php

Member
Member
PrimeMover   15-12-2014, 04:24
#5

Yes and no.

Say I'm running a page at www.domain.com/gallery/

I make a link to "/image.jpg"

html/css will try to find an image at:
www.domain.com/image.jpg

php will try to find an image at:
www.domain.com/gallery/image.jpg

Where the slash tells html and css to back up to the root of the directory, php ignores this, interpreting it as just being in the current directory. This is a really nice handy syntax in html/css, but now that I think about it, I don't think I've encountered it in any other languages.

"/directory" really isn't relative OR absolute in html/css, it's sort of like a third type of link, as it's handled quite differently from the above links.

EDIT: Ahhh, I did some research and this is referred to as a "root-relative" link, and is thought of as separate from absolute and relative linking. They are specific to client-side environments (html/css/js). Server-side environments like php/python have no specific concept of the domain root.

  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.