SSI & Php include

tillabong

New Member
Messages
60
Reaction score
0
Points
0
hi im new to web designing. i've created a website with multiple sub-folders. for all the webpages i have a navigation bar which contains images.

i've tired using SSI to link the navigation.shtml file but didnt work. php include worked for me. however the images dont appear correctly since the links are different for each folders and subfolers.

for example, www.mywebsite.com/navigation.php is where i've kept the navigation. www.mywebsite.com/images/ is where i kept the images in the navigation. webpages that are within the top most folder will display the images correctly when i link the navigation file.

however for webpages like www.mywebsite.com/animals/red/green.php if i link the navigation files the images wont appear since the direct links to the images are not correct. is there any way i could use one navigation file and link to all webpages in different subfolers? or do i have to create a similar navigation and images folder and place it in all subdfolders so the links to the images will work?

sorry correct me if im wrong. external css links images relative to the css files itself and not from the file that contains the external css file. and php include and ssi does otherwise right?

sorry it may sound a little confusing. really hope someone could help me clarify this.

thanks alot.



Edit:
sorry i've got another doubt if a file has the link logout.php it is a relative link to where the file is. if the link is /logout.php the link becomes relative to the root folder? cause if i add the / in front all the image link in my navigation file the problem is solved and all the images work fine when i link it to any file in any subfolder.

sorry for all the trouble.
 
Last edited:

scc123

New Member
Messages
18
Reaction score
0
Points
0
Could you put navigation.php in public_html?
Then when you include just use include('/navigation.php'); and that should include it...
Don't quote me on that though xD
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
@tillabong: it's not entirely clear from your post where the problem lies. When applicable, you should always post a code sample (a minimal test case) to clarify. Also, there's no need to make up URLs. You're asking about your site, so why not simply post the URL for a live page?

One thing to keep in mind is that SSI and PHP are server side, while HTML, CSS are client side. As a consequence, any paths used in HTML or CSS are URL paths, while server side functions (with the notable exceptions of the SSI #include virtual command and PHP's virtual()) use filesystem paths. Each kind of path has a different root. URL paths get translated to filesystem paths, but that doesn't matter much here.

The thread "php include - above root directory" has some nformation about the include and include_once PHP functions. The PHP documentation for these functions has yet more info. Read that over and see if it clears up your confusion.
 

tillabong

New Member
Messages
60
Reaction score
0
Points
0
sorry so much for the trouble and confusion. i've solved it.

thank you very much for your replies.
 
Top