1 / 11

Server-side includes

Server-side includes. Library and Information Services University of St Andrews. What are server-side includes (SSI)?. Mechanism of employing the web server to perform certain tasks displaying files as part of other files displaying information dynamically (dates, URLs) Server support needed.

marly
Download Presentation

Server-side includes

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Server-side includes Library and Information Services University of St Andrews

  2. What are server-side includes (SSI)? • Mechanism of employing the web server to perform certain tasks • displaying files as part of other files • displaying information dynamically (dates, URLs) • Server support needed

  3. File extensions: .html  .shtml • Files containing SSI are html files • Server only parses files with extension .shtml for SSI • Rename/save any files that contain SSI directives as .shtml

  4. SSI directives • Code inserted into html source of a document • Syntax: • <!--#element attribute=“value” --> • <!--#element attribute1=“value1” attribute2=“value2” --> • Various elements (e.g. “include”, “echo”, “config”) and attributes to go with these elements

  5. SSI elements: include • Syntax: <!--#include virtual=“path/file.html” --> • Inserts a file into another file • Including file: file that contains the SSI directive • Included file: file that is displayed as part of another file

  6. <html> <head> <title>SSI demo</title> </head> <body> <h1>SSI demo</h1> <p>Some text …</p> <!--#include virtual=“file.html” --> <p>some more text …</p> </body> </html> <!-- *** file.html *** vis SSI --> <p>School of Pottery <br />University of St Andrews <br />St Andrews <br />Fife <br />KY16 9AJ</p> <p>Email: <a href=“mailto:pottery@st-andrews.ac.uk>pottery@st-andrews.ac.uk</a> </p> <!-- *** End of file.html *** --> Including and included files Including file Included file

  7. Including and included file <html> <head> <title>SSI demo</title> </head> <body> <h1>SSI demo</h1> <p>Some text …</p> <!-- *** file.html *** vis SSI --> <p>School of Pottery <br />University of St Andrews <br />St Andrews <br />Fife <br />KY16 9AJ</p> <p>Email: <a href=“mailto:pottery@st-andrews.ac.uk>pottery@st-andrews.ac.uk</a></p> <!-- *** End of file.html *** --> <p>some more text …</p> </body> </html>

  8. SSI elements: echo • Displaying URLs dynamically • Syntax: <!--#echo var=“HTTP_HOST” var=“DOCUMENT_URI” --> • Displaying last modified date dynamically • Sxntax: <!--#echo var=“LAST_MODIFIED” --> • Displaying date and time dynamically • Syntax: <!--#echo var=“DATE_LOCAL” -->

  9. SSI elements: config • Configure current and last modified time stamps • Syntax: <!--#config timefmt=“%A, %d %B %Y” --> Directiveappears immediately in front directive for time stamp <!--#config timefmt=“%A, %d %B %Y” --> <--#echo var=“DATE_LOCAL” --> will display e.g. Wednesday, 12 November 2003

  10. Timefmt: values • Server dependent • Some values that can be used in St Andrews: %a Abbreviated day name %A Full day name %d Day as number (1-31) %b Abbreviated month name %B Full month name %m Month as number (1-12) %H Hour as number (24-hour clock) %I Hour as number (12-hour clock) %M Minute as number (00-59) %S Second as number (00-59) %Y Year

  11. Why use SSI? • For templates: • to ensure consistent layout • Content management on institutional web sites • Control privileges of various web masters • Avoiding unnecessary duplication of repetitive content • Ease of updating • Time management

More Related