Welcome to WebmasterWorld Guest from 54.158.238.108

Forum Moderators: incrediBILL

Message Too Old, No Replies

How to have an #include call another #include!

Can't believe I didn't think of this sooner

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

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 12, 2003
posts:1199
votes: 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.
10:02 am on Aug 4, 2010 (gmt 0)

New User

5+ Year Member

joined:May 27, 2010
posts: 13
votes: 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
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members