ZenphotoCMS Forum
Relative Links not working while styling - Printable Version

+- ZenphotoCMS Forum (https://forum.zenphoto.org)
+-- Forum: Support (https://forum.zenphoto.org/forum-1.html)
+--- Forum: General support (https://forum.zenphoto.org/forum-4.html)
+--- Thread: Relative Links not working while styling (/thread-12143.html)



Relative Links not working while styling - PrimeMover - 13-12-2014

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?




Relative Links not working while styling - gjr - 13-12-2014

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:

`

`




Relative Links not working while styling - PrimeMover - 14-12-2014

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.




Relative Links not working while styling - gjr - 14-12-2014

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




Relative Links not working while styling - PrimeMover - 15-12-2014

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.