Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    Regular Coder
    Join Date
    Aug 2011
    Posts
    192
    Thanks
    112
    Thanked 0 Times in 0 Posts

    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

  • #2
    Regular Coder dan-dan's Avatar
    Join Date
    Aug 2009
    Location
    England
    Posts
    483
    Thanks
    22
    Thanked 79 Times in 78 Posts
    Are you sure it's just 'one' folder in the way eg: root/folder/folder/file.shtml

    Does it work using the absolute path?

  • Users who have thanked dan-dan for this post:

    Buffmin (03-15-2012)

  • #3
    Regular Coder
    Join Date
    Aug 2011
    Posts
    192
    Thanks
    112
    Thanked 0 Times in 0 Posts
    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.

  • #4
    Regular Coder dan-dan's Avatar
    Join Date
    Aug 2009
    Location
    England
    Posts
    483
    Thanks
    22
    Thanked 79 Times in 78 Posts
    Does it work with http://www.yoursite.com/footer.shtml?

  • Users who have thanked dan-dan for this post:

    Buffmin (03-15-2012)

  • #5
    Regular Coder dan-dan's Avatar
    Join Date
    Aug 2009
    Location
    England
    Posts
    483
    Thanks
    22
    Thanked 79 Times in 78 Posts
    Is the page in which your trying to include the file a HTML or SHTML?

  • Users who have thanked dan-dan for this post:

    Buffmin (03-15-2012)

  • #6
    Regular Coder
    Join Date
    Aug 2011
    Posts
    192
    Thanks
    112
    Thanked 0 Times in 0 Posts
    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.

  • #7
    Regular Coder dan-dan's Avatar
    Join Date
    Aug 2009
    Location
    England
    Posts
    483
    Thanks
    22
    Thanked 79 Times in 78 Posts
    I've heard of problems between html and shtml and needing to add to htaccess. Otherwise I don't know.

  • Users who have thanked dan-dan for this post:

    Buffmin (03-15-2012)

  • #8
    Regular Coder
    Join Date
    Aug 2011
    Posts
    192
    Thanks
    112
    Thanked 0 Times in 0 Posts
    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.

  • #9
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    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.

  • Users who have thanked Fou-Lu for this post:

    Buffmin (03-15-2012)

  • #10
    Regular Coder
    Join Date
    Aug 2011
    Posts
    192
    Thanks
    112
    Thanked 0 Times in 0 Posts
    I tried <!--#include file="/footer.shtml" -->
    Still no good.

  • #11
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    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.

  • Users who have thanked Fou-Lu for this post:

    Buffmin (03-15-2012)

  • #12
    Regular Coder
    Join Date
    Aug 2011
    Posts
    192
    Thanks
    112
    Thanked 0 Times in 0 Posts
    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.

  • #13
    Regular Coder
    Join Date
    Aug 2011
    Posts
    192
    Thanks
    112
    Thanked 0 Times in 0 Posts
    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.

  • #14
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Right, so... exactly what I suggested

  • Users who have thanked Fou-Lu for this post:

    Buffmin (03-16-2012)

  • #15
    Regular Coder
    Join Date
    Aug 2011
    Posts
    192
    Thanks
    112
    Thanked 0 Times in 0 Posts
    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


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •