shortcut to content
Minnesota State University, Mankato
Minnesota State University, Mankato

Latest information about COVID-19 and the campus community

×

Template PHP Functions

Page address: https://web.mnsu.edu/its/web/editing/template/documentation/functions.html

Filelink

<?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. http://www.mnsu.edu/file.pdf, not www.mnsu.edu/file.pdf)

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[http://www.google.com/intl/en/images/logo.gif]'); ?>

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

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.

Slidefiles

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.

Examples

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}'); ?>

Notes

  • 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>