Layout container SSI hack
I finally found a more likable organizational structure for this site’s content. Previously, I had an index.shtml
that included a file depending on the query string. Now, you now get sent directly to the .shtml
in question.
The trick is in how to avoid having to include header and footer separately in this file: by setting $PAGE_NAME
to $DOCUMENT_URI
and including /template.shtml
, which in turn uses $PAGE_NAME
to include the file that just included it. Recursion doesn’t happen, because each page checks whether $PAGE_NAME
is set before it calls for /template.shtml
.
In short, the whole thing inside each individual page looks like this:
<!--#if expr="$PAGE_NAME" -->
Page content goes here
<!--#else
--><!--#set var="PAGE_NAME" value="$DOCUMENT_URI"
--><!--#include virtual="/template.shtml"
--><!--#endif
-->
Having to have this in every file is still too much duplication for my taste, but at least it doesn’t vary between files (it doesn’t need, say, individual $PAGE_NAME
values or something).
The corresponding bits in the central /template.shtml
simply look like this:
<!--#if expr="! $PAGE_NAME"
--><!--#set var="PAGE_NAME" value="/index.shtml"
--><!--#endif
--><!--#include virtual="$PAGE_NAME"
-->
Referenced in More layout container SSI hacking.