Swiffit2 home icon

Server Side Includes

Swiffit runs on Apache servers and therefore SSI is a great tool for designing webpages. Here's some easy access good to know SSI codes.

Detect browser type

<p>
<!--#if expr="$http_user_agent = /MSIE 6.0/" -->

You're using Internet Explorer 6.0.
<!--#elif expr="$http_user_agent = /MSIE [7-9]/" -->
You're using Internet Explorer 7 or newer
<!--#elif expr="$http_user_agent = /Safari/  && $http_user_agent = /Windows/" -->
You're using Safari on windows!
<!--#elif expr="$http_user_agent = /Safari/" -->
You're using Safari!
<!--#elif expr="$http_user_agent = /Firefox/"   -->
You're using Firefox!
<!--#else -->
Other or unknown browser
<!--#endif -->
</p>

Finding the current Domain and Folder

<!--#if expr="$DOCUMENT_URI = /\/([^\/]+)\/([^\/]+)\/([^\/]+)/"
--><!--#set var="FOLDER" value="$3"
--><!--#set var="DOMAIN" value="$2"

--><!--#else
--><!-- if root or frontpage: Set DOMAIN - and FOLDER default

--><!--#set var="FOLDER" value="main"
--><!--#set var="DOMAIN" value="${SITE_NAME}"

--><!--#endif-->

Using variables and rules

<!--#if expr="${FOLDER} = /main/" -->

<p>Du er i main</p>

<!--#else -->

<p><a href="/pub/<!--#echo var="DOMAIN"-->/main/">Gå til main</a></p>

<!--#endif -->

Publisert: 14.08.09 10:34 Bookmark and Share