Aquiring site content from folders

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
MrPotatoes
Forum Regular
Posts: 617
Joined: Wed May 24, 2006 6:42 am

Aquiring site content from folders

Post by MrPotatoes »

this is a question that i honsetly haven't been able to figure out on my own. normally i do but this one has really been bothering me

i have resources on my webserver (local) and this system has a specific folder structure and way of doing things. currently the way that i have it i include the files that i need and work from there. takes alot of the guess work out of knowing how to do my includes in other files.

now, my images are in a folder from the root index called "images". so it looks like this:

Code: Select all

index.php
    +---images
    +---templates
    +---includes
here is my question. in C++ i'm used to just telling it where my static content is. in which folder depending on which folder i am in. well i tried that and it doesn't seem to listen to me. instead what i have to do is give it the "directions" via the URL. like this: 'http://localhost/framework/templates/de ... /error.css'

i would prefer to tell it where it is in a fashion like i do includes. relative to the folder that is including. so, for instance. when i am in the index.php and i include something the include structure is relative to index.php. not the URL.

so i wanted my html/code to end up looking like

<img src="templates/default/styles/error.css"></img>

and not like:
<img src="http://localhost/framework/templates/de ... css"></img>


thanx for the help

[edit] and yes. i have tried giving it the EXACT path to the content
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Build the full URL of the target file, build the full URL of the current file. Remove what is the same.

viewtopic.php?p=199996&highlight=geturl#199996 could be of interest.
User avatar
MrPotatoes
Forum Regular
Posts: 617
Joined: Wed May 24, 2006 6:42 am

Post by MrPotatoes »

friend helped me figure it out. much simpler than i thought it would be. i needed to add the '/' beginning and remove everything else. that makes it relative. that takes a load off my back.

not happy about the way that it works though lol but i'm happy that it does :D

feel free to lock it up
Post Reply