Page address:

MSU Web Template Functions:


<?php filelink('Name of Link[/link/file.pdf]'); ?>

Filelink is a function built into the University Web Template core to standardize and facilite linking of non-web files. It can create links to local files or remote files, with some caveats. In addition to link text, it will automatically display the file type and size after the link.

Filelink only supports:

  • root-relative URLs (e.g. /dir/file.ext, not file.ext)
  • full web URLs (e.g., not

Bear in mind that filelink should only be used to create links to files you expect a visitor to download - it is not a way to create links to other web pages.

A root-relative link to a local file

<?php filelink('Printable FAQs[/nursing/faq.pdf]'); ?>

Text on the webpage will look like this: [PDF]Printable FAQs(8KB PDF)

A link to a remote file

<?php filelink('Google Logo[]'); ?>

Text on the webpage will look like this: [GIF]Google Logo(8KB)

Readfile and Scriptmtime

<?php Readfile($_SERVER['DOCUMENT_ROOT'] . '/link/common/page.html');?>

Readfile is a function that is used to share the contents of one file on multiple pages.

To use paste the shared content into a blank html page with no Smartbuilder code. We usually save this file in a folder called /common/ in the directory of the website that will be sharing the content. Next, in the content area of the Smartbuilder page you want to share this content, place the Readfile code.

To make sure that the modified date is updated on the Smartbuilder page every time the common page is changed place the $SCRIPTMTIME = filemtime($_SERVER['DOCUMENT_ROOT'] . '/link/common/page.html'); up in the Smartbuilder code. You can place it after $contentcolumns code.


Slideshow is a University Web Template core function designed to easily create a javascript-powered image 'rotater'.

<?php slideshow(' Image's Alt Text [ path to images ]{ navigation options } '); ?>

Where path_to_images is:

  • A root-relative path to a directory. In this case, every image file in the directory will be used. E.g. /dir/images/
  • A root-relative path to a single image file. E.g. /dir/image.jpg
  • Any combination of the preceding two forms, separated by pipes (e.g. [/dir/to/images/|/some/image.jpg|/some/otherimage.jpg])
  • A root-relative path to a "slidefile". E.g. /dir/slides.php

Navigation options may contain any combination of the following entries, in any order:

  • auto - Specifies that the image should auto-rotate. The default rotation method is an 11-second automatic rotation.
  • text - The text '<< Previous Next >>' will appear below the images (as links that move forward and backward in the slideshow).
  • images - VCR-style navigation buttons will appear below the images to step through the slideshow.

If both {images} and {text} are specified, {text} will be ignored.


A slidefile is a text file (with a .php or .smbl extension) that defines the slides in a slideshow. It is the only method available that supports captions.

You point to a slidefile the same way you'd point to a regular image: a root-relative path. If you wish to use a slidefile, it must be the first and only path provided to the slideshow function.

The contents of a slidefile are similar to the University Web Template $leftmenu definitions. A single line might look like this:

$slide[] = 'Me at the beach - look at that crazy seagull![/trips/oregon/images/seagull.jpg]';

This specifies a caption, and an image to go with it. Note that the $slides[] is mandatory - if you use a different name, or forget the [], it will not work. Any number of slides can be specified this way.


Given a directory /stuff/images/ that contains 5 images, the following code would create a slideshow of all the images inside it, with the alt text "My Slideshow", and VCR-style navigation buttons:

<?php slideshow('My Slideshow[/stuff/images/]{images}'); ?>

This example would create the same slideshow, with one extra picture (located at /other/images/image1.jpg), and using text-based navigation:

<?php slideshow('My Slideshow[/stuff/images/|/other/images/image1.jpg]{text}'); ?>

This code would create a slideshow using slides defined by a slidefile, rotating automatically, with image navigation:

<?php slideshow('My Slideshow[/stuff/slides.php]{images auto}'); ?>


  • All the images used by a given slideshow must have exactly the same dimensions - that is, they must all have the same width and height. If one of the images is a different size than the others, the program will crash and show an error on the webpage - this is deliberate.
  • For the purposes of the slideshow, an "image" is a file with any one of the following file extensions: jpg jpeg png
  • Typically, you will want to wrap the entire slideshow in a div or some other XHTML container so you can apply formatting. For example, to create a slideshow that displays on the right side of the page, you might code:
    <div class='floatright'> <?php slideshow('New Facilities[/office/facilities-update/images/]{images}'); ?></div>


What is CAPTCHA?

CAPTCHA (acronym for "Completely Automated Public Turing test to tell Computers and Humans Apart") means using distorted images, among other techniques, to prevent spam generation using web page forms.

The CAPTCHA element we have implemented in SMBL asks the person submitting a form to type in the letters they see in the distorted image before the form is submitted. Once a person submits a form it then sends them to the page where they have to type in the letters they see on the screen. This added feature prevents bots from automatically spamming through email forms.

Download a [ZIP] CAPTCHA contact form (2 KiB)

Below is the code you need to implement CAPTCHA into any SMBL form.

Page Titles, Breadcrumbs, and Navigation

First insert the php code to initiate the session. This code also defines errors for invalid entries. See the example:

ini_set('session.use_cookies', '1');
session_set_cookie_params ( 0 , '/' , '');
define('ERROR_REQUIRES_VALUE', '<br /><span class="error eleven">Please specify</span>');
define('ERROR_INVALID_EMAIL', '<br /><span class="error eleven">Invalid email</span>');
define('ERROR_INVALID_LETTERS', '<br /><span class="error eleven">Letters only, please</span>');
define('ERROR_INVALID_NUMBERS', '<br /><span class="error eleven">Numbers only, please</span>');
define('ERROR_INVALID_TELEPHONE', '<br /><span class="error eleven">Invalid telephone: 555-555-5555</span>');

After 'Submit' Has Been Clicked

Next, insert the code to determine if the entered information is valid:

$postback = count($_POST) ? true : false;
if($postback == true) {
  $names = array('firstname', 'firstname', 'lastname', 'lastname', 'email', 'email', 'comment', 'confirm');
  $types = array('letters', 'required', 'letters', 'required', 'email', 'required', 'required', 'required');
  $values = $_POST;
  $results = ValidateControls($names, $types, $values);
  $return = $results['return'];
  $errors = $results['errors'];

$names and $types are parallel arrays containing information on every field in the form that needs to be specified or needs to be of one specific type. In the above code, for example, firstname is the ID of the textbox in the form where the user inputs his/her first name. This field is required, but it also must only contain letters. Therefore, the ID is listed in $names at one index (in this case, 0), and 'letters' is listed in the corresponding index in the array $types. firstname is then listed again, with 'required' in the corresponding index in $types.

CAPTCHA Validation and SendEmail

This block of code is placed inside the previous if statement after the $errors line. It determines if the user has correctly entered the CAPTCHA letters. If they are correct, this code sends the information from the form to a file called message.smbl. This is then emailed to a specified receiver.

  if ($_SESSION['php_captcha'] == strtoupper($_POST['confirm'])) {
    if($return == true) {
     $email = $_POST['email'];
     $message = ob_get_contents();
     SendEmail($email, '', 'Web Services Contact Form', $message);
    $errors['confirm'] = "<span class='error eleven'>Please type in the right letters</span>";

SendEmail is a function with four parameters: $email, 'email_address', 'subject', and $message.

  • $email contains the email address that the user entered in the textbox named 'email'. This appears in the 'from' section of the email.
  • The 'email_address' is the address that the email will be sent to. In the above example, the email will be sent to
  • 'subject' is the subject of the email. This usually reads '(Department Name) Contact Form'
  • $message contains the form information.

Body Options

Contact forms usually have a section entitled "Relationship to MSU", which typically consists of four radio buttons. The last of these is named "Other", and when clicked, a textbox appears. The code that determines the visibility of this textbox is listed below. It is typically placed after the if($postback == true) if statement.

$bodyoptions='onload="javascript:document.getElementById(\'other\').checked ? document.getElementById(\'otherspecify\').style.visibility=\'visible\' : document.getElementById(\'otherspecify\').style.visibility=\'hidden\'"';

Header and Navigation Information

After the $bodyoptions section is the typical code for headers and left navigation:


Using the response.smbl File

The code enabling the page to use the response.smbl file is shown below.

if(($_SESSION['php_captcha'] == strtoupper($_POST['confirm'])) && ($return == true)){

Form Code

The following is the code for a typical Contact Form.

<form id="mrcontact" method="post" action="/path_to_form/">
  <div class="margin-bottom nopadding clearboth">
    <input type="hidden" id="tagType" value="span" />
    <p class="floatleft padding-right nomargin-top margin-bottom"><label for="firstname" class="bold">First name:</label><br />
    <input type="text" id="firstname" name="firstname" value="{$_POST['firstname']}" style="width: 130px;" />{$errors['firstname']}</p>
    <p class="floatleft padding-right nomargin-top margin-bottom"><label for="lastname" class="bold">Last name:</label><br />
    <input type="text" id="lastname" name="lastname" value="{$_POST['lastname']}" style="width: 130px;" />{$errors['lastname']}</p>
    <p class="floatleft clearright nomargin-top margin-bottom"><label for="email" class="bold">Email:</label><br />
    <input type="text" id="email" name="email" value="{$_POST['email']}" style="width: 130px;" />{$errors['email']}</p>

"Relationship with MSU" Section

  <div class="margin-top nopadding clearboth">
    <p class="nopadding"><strong>What's your relationship with MSU?</strong><br />
    <input type="radio" name="status" value="Student" id="student" onclick="javascript:document.getElementById('otherspecify').style.visibility='hidden'" /><label for="student">Student</label>
    <input type="radio" name="status" value="Alumni" id="alumni" onclick="javascript:document.getElementById('otherspecify').style.visibility='hidden'" /><label for="alumni">Alumni</label>
    <input type="radio" name="status" value="Employee" id="employee" onclick="javascript:document.getElementById('otherspecify').style.visibility='hidden'" /><label for="employee">Employee</label>
    <input type="radio" name="status" value="Other" id="other" onclick="javascript:document.getElementById('otherspecify').style.visibility='visible'" /><label for="other">Other</label><span id="otherspecify">:<input type="text" id="role" name="otherspecify" value="{$_POST['otherspecify']}" style="width: 130px;" /></span></p>

Code for the Comment Box

  <div class="margin-top nopadding clearboth">
    <p class="nopadding"><label for="comment" class="bold">Your comment or question:</label>{$errors['comment']}<br />
    <textarea id="comment" name="comment" cols="36" rows="10" style="width: 424px;">{$_POST['comment']}</textarea></p>

Code for CAPTCHA

This code is placed immediately before the "Submit" button.

  <div class="margin-bottom nopadding clearboth">
    <p><img src="/util/captcha/visual-captcha.php" alt="Visual CAPTCHA" /></p>
    <p><a href="/util/captcha/audio-captcha.php">Can't see the image? Click for audible version</a></p>
  <div class="margin-bottom nopadding clearboth">
    <p class="floatleft padding-right margin-bottom"><label for="confirm" class="bold">Please type in the letters you see.</label><br />
    <input type="text" id="confirm" name="confirm" value="{$_POST['confirm']}" style="width: 190px;" /> {$errors['confirm']}</p>

Ending Code

  <div class="margin-bottom nopadding clearboth">
    <input id="submit" type="submit" value="Submit" />

message.smbl File

The message.smbl file should be placed in the same folder as the form. This file contains the information that will be sent via email to the recipient specified in the SendEmail section of the form code. The message.smbl file should include all of the questions from the form, along with their corresponding answers. For example:

<p><strong>First name:</strong> {$values['firstname']}<br />
<strong>Last name:</strong> {$values['lastname']}<br />
<strong>Email:</strong> {$values['email']}<br />
<strong>At MSU:</strong> {$values['status']} {$values['otherspecify']}<br />
<strong>Comment:</strong> {$values['comment']}</p>

response.smbl File

The response.smbl file should also be placed in the same folder as the form. This file displays after the form has been correctly filled out and submitted. Here is an example:

<h2>Form Submitted</h2>
<p><strong>First name:</strong> {$values['firstname']}<br />
<strong>Last name:</strong> {$values['lastname']}<br />
<strong>Email:</strong> {$values['email']}<br />
<strong>At MSU:</strong> {$values['status']} {$values['otherspecify']}<br />
<strong>Comment:</strong> {$values['comment']}</p>
<p class="gray1">Please do not reload this page to avoid duplicate messages.</p>