Building Web Projects

with Server-Side Includes, a little Perl, and some JavaScript
Example for the Intelligent Footers Article

Example for the Intelligent Footers Article

Test page

Below, is the test page. Pretend it's all you see and the rest of this article will discuss it.

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Cursus eget nunc scelerisque viverra mauris in aliquam sem. Amet massa vitae tortor condimentum lacinia quis. Porttitor leo a diam sollicitudin tempor id eu nisl nunc. Mattis ullamcorper velit sed ullamcorper morbi tincidunt ornare massa eget. Eu feugiat pretium nibh ipsum consequat nisl vel pretium lectus. Odio tempor orci dapibus ultrices in iaculis nunc. Turpis nunc eget lorem dolor sed viverra ipsum nunc. Sed arcu non odio euismod lacinia at quis risus. Diam vel quam elementum pulvinar etiam non quam. At ultrices mi tempus imperdiet nulla malesuada pellentesque elit eget. Sapien faucibus et molestie ac feugiat sed lectus vestibulum. Suspendisse in est ante in.

Lastest News

Latest News

Here's some content for the Latest News include.

Latest News Last Updated: Thursday, May 16, 2024 07:29:53

Malesuada bibendum arcu vitae elementum curabitur vitae nunc. Vitae semper quis lectus nulla at volutpat. Nunc pulvinar sapien et ligula ullamcorper malesuada. Aliquam ut porttitor leo a diam sollicitudin tempor. Vitae proin sagittis nisl rhoncus mattis rhoncus urna neque viverra. Velit sed ullamcorper morbi tincidunt ornare massa eget egestas purus. Sodales neque sodales ut etiam sit amet nisl purus in. Nullam non nisi est sit amet facilisis magna etiam tempor. Suspendisse sed nisi lacus sed viverra tellus in hac habitasse. Sed viverra ipsum nunc aliquet. Ultrices mi tempus imperdiet nulla malesuada. Nunc mattis enim ut tellus elementum sagittis. Volutpat lacus laoreet non curabitur gravida arcu ac tortor. Adipiscing elit pellentesque habitant morbi. Et pharetra pharetra massa massa.

Host Page Last Updated: Tuesday, December 03, 2024 07:23:35


Below is the code for the host page, example.shtml, and the included snippet, latest-news.inc.shtml. Notice that I made the included snippet a .shtml file so that in it I could use SSI to shows it's last modified date. I did this so that you can see the different last modified dates for the two file. Below, the last modified date will be the most recent of the two because I'm using footer.pl as desceribed in the article.

example.shtml

Here's a portion of the code for the host page, example.shtml, above. (Yes, I realize there's too much lorem imsum stuff but I wanted enough content to better show the Lastest News snippet position on the page.)

<article>
   <p>
      Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Cursus eget nunc scelerisque viverra mauris in aliquam sem. Amet massa vitae tortor condimentum lacinia quis. Porttitor leo a diam sollicitudin tempor id eu nisl nunc. Mattis ullamcorper velit sed ullamcorper morbi tincidunt ornare massa eget. Eu feugiat pretium nibh ipsum consequat nisl vel pretium lectus. Odio tempor orci dapibus ultrices in iaculis nunc. Turpis nunc eget lorem dolor sed viverra ipsum nunc. Sed arcu non odio euismod lacinia at quis risus. Diam vel quam elementum pulvinar etiam non quam. At ultrices mi tempus imperdiet nulla malesuada pellentesque elit eget. Sapien faucibus et molestie ac feugiat sed lectus vestibulum. Suspendisse in est ante in.
   </p>

   <!--#include file="latest-news.inc.shtml" -->

   <p>
      Malesuada bibendum arcu vitae elementum curabitur vitae nunc. Vitae semper quis lectus nulla at volutpat. Nunc pulvinar sapien et ligula ullamcorper malesuada. Aliquam ut porttitor leo a diam sollicitudin tempor. Vitae proin sagittis nisl rhoncus mattis rhoncus urna neque viverra. Velit sed ullamcorper morbi tincidunt ornare massa eget egestas purus. Sodales neque sodales ut etiam sit amet nisl purus in. Nullam non nisi est sit amet facilisis magna etiam tempor. Suspendisse sed nisi lacus sed viverra tellus in hac habitasse. Sed viverra ipsum nunc aliquet. Ultrices mi tempus imperdiet nulla malesuada. Nunc mattis enim ut tellus elementum sagittis. Volutpat lacus laoreet non curabitur gravida arcu ac tortor. Adipiscing elit pellentesque habitant morbi. Et pharetra pharetra massa massa.
   </p>
   <p>
      <!--#config timefmt="%A, %B %d, %Y" -->
      <strong>Host Page Last Updated:  <!--#echo var="LAST_MODIFIED" --></strong>
   </p>

   <br style="clear: both;">
</article>

Here is the style section for example.shtml.

<style>
   .example {
      border: 1px solid #aaa;
      margin: 20px;
      padding: 10px 10px 0 10px;
      background-color: #eee;
   }
   .reference {
      margin-top: 100px;
      border-top: 1px solid #aaa;
   }
   .printonly {
      display: none;
   }
   @media print {
      .printonly {
         display: inline;
      }
   }
</style>

latest-news.inc.shtml

Here's a portion of the code for the Latest News snippet, latest-news.inc.shtml.

<div class="news">
   <h2>Latest News</h2>
   <p>
      Here's is some content for the Latest News snippet.      
   </p>
   <p>
      <!--#config timefmt="%A, %B %d, %Y" -->
      <strong>Snippet Last Updated:  <!--#echo var="LAST_MODIFIED" --></strong>
   </p>
</div>

Here is the style section for latest-news.inc.shtml.

<style>
   .news {
      font-family: 'Times New Roman', Times, serif;
      width: 25%;
      float: right;
      border: 1px solid #aaa;
      padding: 5px 5px 0 5px;
      margin-left: 20px;
   }
   .news h2 {
      margin-top: 0;
   }
</style>

Implementing intelligent-footer.pl

Passing a File Name in the Query String

Now, this section is to show that implementing intelligent-footer.pl I can get the LAST_MODIFIED date for the webpage to show the most recent LAST_MODIFIED date of either the host file, example.shtml, or the included snippet, latest-news.inc.shtml.

So, I have put this line in the example.shtml file.

<!--#include virtual="/cgi-bin/intelligent-footer.pl?latest-news.inc.html" -->

and the LAST_MODIFIED date, shown below, is the LAST_MODIFIED of the most recent of the two shown above. Notice that the Last Updated date is that of the included file.

NOT Passing a File Name in the Query String

intelligent-footer.pl works just fine without passing a file name in the query string. Just use the following in your code.

<!--#include virtual="/cgi-bin/intelligent-footer.pl" -->

Below the results are for inserting that line. Notice that the Last Updated date is that of the host file.

This is an example of using the ideas in the article Intelligent Footers

Return to the article.