homepage Welcome to WebmasterWorld Guest from 50.17.7.84
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / HTML
Forum Library, Charter, Moderators: incrediBILL

HTML Forum

    
How to have an #include call another #include!
Can't believe I didn't think of this sooner
MichaelBluejay




msg:4157362
 4:53 am on Jun 23, 2010 (gmt 0)

I use the .ssi extension for my includes, to differentiate the files on my server from pages. Early on I learned that my included file couldn't call another include. For example, if the "sidebar.ssi" code was:
The lamb lies down on Broadway.
<!--#include virtual="secondInclude.ssi"-->

then my page would show "The lamb..." sentence, but it would end there. It wouldn't pull in the secondInclude.

For years I thought that was a limitation of SSI, but it's not. The reason the second .ssi wasn't included is that the server didn't know to look for it, because I never told it to scan .ssi files for includes! All I had to do was add that to my .htaccess file:
AddHandler server-parsed .html .ssi

And Ta-Da! Now includes can call other includes.

I hope this helps somebody.

By the way, when searching around about SSI extensions, I found this article on SSI extensions for refugees [nilc.org], which wasn't exactly what I was looking for.

 

SEO_Shruti




msg:4181705
 10:02 am on Aug 4, 2010 (gmt 0)

You can also use it in other way. For that the same condition applies that ssi is enabled. You can include a html file in another file. Suppose, you want to include matter of file B.html in A.html include the code <!--#include file="b.html" --> where you want to place that content and save a.html to a.shtml

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / HTML
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved