Go Back   CodingForums.com > :: Server side development > Other server side languages/ issues

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-15-2012, 09:27 PM   PM User | #1
Buffmin
Regular Coder

 
Join Date: Aug 2011
Posts: 192
Thanks: 112
Thanked 0 Times in 0 Posts
Buffmin is an unknown quantity at this point
Can't do include from sub-folder.?

I have a normal shtml file.
I use
<!--#include file="footer.shtml" --> on my index page to include my footer.

I have a page in in a sub-folder and would also like to include that footer,but when I do
<!--#include file="../footer.shtml" -->
It does not get included on the sub page. Not sure why?
Any help would be appreciated. Thanks. Buffmin
Buffmin is offline   Reply With Quote
Old 03-15-2012, 09:40 PM   PM User | #2
dan-dan
Regular Coder

 
dan-dan's Avatar
 
Join Date: Aug 2009
Location: England
Posts: 483
Thanks: 22
Thanked 79 Times in 78 Posts
dan-dan is on a distinguished road
Are you sure it's just 'one' folder in the way eg: root/folder/folder/file.shtml

Does it work using the absolute path?
dan-dan is offline   Reply With Quote
Users who have thanked dan-dan for this post:
Buffmin (03-15-2012)
Old 03-15-2012, 09:48 PM   PM User | #3
Buffmin
Regular Coder

 
Join Date: Aug 2011
Posts: 192
Thanks: 112
Thanked 0 Times in 0 Posts
Buffmin is an unknown quantity at this point
Yes, it is definitely one folder down. Not sure how to set the absolute path. You mean using the url?

I did try the <!--#include file="http://www.mysitename.com/footer.shtml" -->

No help.

I see thatb there is aome kind of trick to using includes from sub-folders (but I don't know it!)

Last edited by Buffmin; 03-15-2012 at 09:53 PM..
Buffmin is offline   Reply With Quote
Old 03-15-2012, 09:53 PM   PM User | #4
dan-dan
Regular Coder

 
dan-dan's Avatar
 
Join Date: Aug 2009
Location: England
Posts: 483
Thanks: 22
Thanked 79 Times in 78 Posts
dan-dan is on a distinguished road
Does it work with http://www.yoursite.com/footer.shtml?
dan-dan is offline   Reply With Quote
Users who have thanked dan-dan for this post:
Buffmin (03-15-2012)
Old 03-15-2012, 10:03 PM   PM User | #5
dan-dan
Regular Coder

 
dan-dan's Avatar
 
Join Date: Aug 2009
Location: England
Posts: 483
Thanks: 22
Thanked 79 Times in 78 Posts
dan-dan is on a distinguished road
Is the page in which your trying to include the file a HTML or SHTML?
dan-dan is offline   Reply With Quote
Users who have thanked dan-dan for this post:
Buffmin (03-15-2012)
Old 03-15-2012, 10:09 PM   PM User | #6
Buffmin
Regular Coder

 
Join Date: Aug 2011
Posts: 192
Thanks: 112
Thanked 0 Times in 0 Posts
Buffmin is an unknown quantity at this point
Both are shtml

I used the same <!--#include file="footer.shtml" --> that I used in the index.shtml file. When it didn't work, I added the ../ and still didn't work. And it is definitely only 1 folder level down.
Buffmin is offline   Reply With Quote
Old 03-15-2012, 10:34 PM   PM User | #7
dan-dan
Regular Coder

 
dan-dan's Avatar
 
Join Date: Aug 2009
Location: England
Posts: 483
Thanks: 22
Thanked 79 Times in 78 Posts
dan-dan is on a distinguished road
I've heard of problems between html and shtml and needing to add to htaccess. Otherwise I don't know.
dan-dan is offline   Reply With Quote
Users who have thanked dan-dan for this post:
Buffmin (03-15-2012)
Old 03-15-2012, 10:35 PM   PM User | #8
Buffmin
Regular Coder

 
Join Date: Aug 2011
Posts: 192
Thanks: 112
Thanked 0 Times in 0 Posts
Buffmin is an unknown quantity at this point
Sorry, all are shtml

I tried it again with a new page. I find that if you include a say.... footer.shtml page and in the same folder, you create a page that has nothing but an include to that page it works fine. (using <!--#include file="footer.shtml" --> )

BUT if you copy that same page to a sub folder, it will no longer include the footer code, even if you add the ../ before the footer.shtml

I just get an error .... [an error occurred while processing this directive]

I don't get it.?

Last edited by Buffmin; 03-15-2012 at 11:18 PM..
Buffmin is offline   Reply With Quote
Old 03-15-2012, 11:13 PM   PM User | #9
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,662
Thanks: 4
Thanked 2,452 Times in 2,421 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
SSI is a server directive. Hmmm, I think I'll move this to the other server side languages forum.

Don't bother with tracking your filepaths. The directive is html root based, just use /footer.shtml if its served off of the root.
Fou-Lu is offline   Reply With Quote
Users who have thanked Fou-Lu for this post:
Buffmin (03-15-2012)
Old 03-15-2012, 11:23 PM   PM User | #10
Buffmin
Regular Coder

 
Join Date: Aug 2011
Posts: 192
Thanks: 112
Thanked 0 Times in 0 Posts
Buffmin is an unknown quantity at this point
I tried <!--#include file="/footer.shtml" -->
Still no good.
Buffmin is offline   Reply With Quote
Old 03-15-2012, 11:27 PM   PM User | #11
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,662
Thanks: 4
Thanked 2,452 Times in 2,421 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Does that include line show up in the comments if you view the source of the page?

Edit:
Wait, change that from file= to virtual=. Does that work?
On a side note, its been yeeeeeaaaaarrrrrssss since I've used an SSI directive. Is there a reason why you are using this instead of a processing language like PHP?

Last edited by Fou-Lu; 03-15-2012 at 11:29 PM..
Fou-Lu is offline   Reply With Quote
Users who have thanked Fou-Lu for this post:
Buffmin (03-15-2012)
Old 03-15-2012, 11:37 PM   PM User | #12
Buffmin
Regular Coder

 
Join Date: Aug 2011
Posts: 192
Thanks: 112
Thanked 0 Times in 0 Posts
Buffmin is an unknown quantity at this point
No it doesn't.
You can see the page at http://cert.cnjwebsolutions.com/garb/junk.shtml

When I view source, below is what I get. (The only thing I put on the page is the footer include)
AND, below that is the original code from my page)
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
 
<body>
 
[an error occurred while processing this directive]
</body>
</html>
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>

<!--#include file="../footer.shtml" -->
</body>
</html>

Last edited by Buffmin; 03-15-2012 at 11:41 PM..
Buffmin is offline   Reply With Quote
Old 03-15-2012, 11:47 PM   PM User | #13
Buffmin
Regular Coder

 
Join Date: Aug 2011
Posts: 192
Thanks: 112
Thanked 0 Times in 0 Posts
Buffmin is an unknown quantity at this point
Got it.
I finally found this in another forum

rather than use <!--#include file="../footer.shtml" -->

Change it to this <!--#include virtual="/footer.shtml" -->

and here is the explanation exact from the forum.

-------------------------
What you have should work fine, basically. Because it does not work, something else is wrong.

any path that starts with a slash means, "Start at the DocumentRoot" -- as defined in the server configuration. So if /inc/example-page.shtml is referenced in an include, but resolves to <DocumentRoot>/sub-folder/inc/example-page.shtml instead of <DocumentRoot>/inc/example-page.shtml, then either your server configuration is faulty, or it is simply not configured the way that you think it is... That is why I asked about the "Control Panel add-ons" above.

[added] Here is the code I use to include a footer on all pages of one of my sites, regardless of what subdirectory the page's file might be located in:

-----------------------

Thank you all !!
Working fine now. Cheers.
Buffmin is offline   Reply With Quote
Old 03-16-2012, 12:06 AM   PM User | #14
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,662
Thanks: 4
Thanked 2,452 Times in 2,421 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Right, so... exactly what I suggested
Fou-Lu is offline   Reply With Quote
Users who have thanked Fou-Lu for this post:
Buffmin (03-16-2012)
Old 03-16-2012, 12:49 AM   PM User | #15
Buffmin
Regular Coder

 
Join Date: Aug 2011
Posts: 192
Thanks: 112
Thanked 0 Times in 0 Posts
Buffmin is an unknown quantity at this point
Wow Fou-Lu.

My apologies. I guess my eyes skimmed over that, thinking it was just one of those tid-bit (phrases) that people seem to include in their threads.

Yes, that is exactly what you suggested.

The other thing that you asked was, why am I not using a processing language like php.

Hmmm, as I am fairly new in this business, I have always had the impression that you should create sites as html unless you are going to include php code, at which time, I would save them as .php.

That has always been a question of mine. If php pages will work fine even if they do not contain php code, then why not just always save pages as php?

I mean, I have a tendancy of creating half a website, and then the client wants a page that will require php. Then, rather than having 10 html pages and '1' php page, I go back and save the other pages as php.?

I would appreciate your thoughts. Thanks again, Buffmin
Buffmin is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:47 AM.


Advertisement
Log in to turn off these ads.