Professional > Interview scripting > Writing interview scripts > Page layout facilities > Templates > Writing templates > Referring to external files
 
Referring to external files
External files are image files, stylesheets, or files containing Javascript that you want to use in the current template. When you write and test a script using UNICOM Intelligence Professional, you may have these files in a different location to where they will be for live interviews. This means that you have to remember to change the references to the files in the template before you activate. A better approach is to name these files in the template using an <mrRef> or <mrSharedRef> tag. The <mrRef> and <mrSharedRef> tags are similar except that the <mrRef> tag is typically used to reference project specific files while the <mrSharedRef> tag is used to reference files that may be shared across projects (like Javascript frameworks used to support custom controls or large media files). Tag usage examples are shown below.
When a template contains an <mrRef> tag and you test your script in UNICOM Intelligence Professional, the interviewing program looks for external files in folders relative to the location of the template. When you activate the project, the <mrRef> locations are prefixed with the image cache URL or, if you are manually copying the files to the web server, with the relative path to the images folder. The interviewing program for live interviews will find the external files without you needing to make any changes to the template.
<mrRef> tag
The syntax of the <mrRef> tag is as follows:
<mrRef RefType="type" RefPosition="position" attribute="value" ...> [Text] </mrRef>
where:
type is the tag name that you would normally use to reference a file of the current type; for example, a for hyperlinks, img for images, link for stylesheets, and script for Javascript files.
position is either head or bottom and indicates that the reference to the file is placed in either the <head> section or the closing body tag of the HTML document that the Player creates for the page. This allows you to use the same custom control more than once on a page without having to repeat the reference for each use.
attribute is an attribute that you would normally specify on the type tag, as follows:
Tag
Attributes Required
<a>
src, alt
<imageCacheURL>
Defines the URL that is used to reference files in the rendered HTML that is sent to the respondent’s browser. For example, <mrRef RefType="imageCacheURL"/> results in the following URL address:
http://<ServerName>/SPSSMR/ImageCache/ImageCache.aspx?Project=<ProjectName>&File=
<img>
src, alt. id is also beneficial. Other attributes may be included as necessary.
<link>
rel, type, href
<script>
type, src
value is the value for that attribute.
There are two general points to remember when using <mrRef>:
The following keywords are case sensitive and must be specified exactly as shown here otherwise the interviewing program will not recognize it and your template will not work: mrRefTag, RefType, href, src.
Not all the HTML tags support the empty tag format: <script>, for instance, does not support the <script/> notation and will not display anything if a tag of this form is read. To avoid this problem, always place some text between the opening and closing<mrRef> tags. If you're referencing a Javascript program, you might like to type a short description of what the program does.
You may define any number of attributes and values simply by listing them one after the other, separated by spaces. When the interviewing program reads the <mrRef> tag, it builds an ordinary HTML tag using the information given with <mrRef>. For example, if the <mrRef> tag is:
<mrRef RefType="img" src="logo.jpg" alt="SPSS logo" border="0">Dummy text</mrRef>
the instructions will be passed to your browser will be:
<img src="logo.jpg" alt="SPSS logo" border="0"/>
Similarly:
<mrRef RefType="link" rel="stylesheet" type="text/css" Standard2.css">Dummy text</mrRef>
becomes:
<link Standard2.css" rel="stylesheet" type="text/css"></link>
<mrSharedRef> tag
The <mrSharedRef> tag provides similar functions as the <mrRef> tag, but locations used in <mrSharedRef> are based on a global location, as defined below:
Web/CATI Survey and UNICOM Intelligence Author Server Edition:
[FMRoot]\Shared\Content
UNICOM Intelligence Interviewer - Offline for Windows, UNICOM Intelligence Author, and UNICOM Intelligence Professional:
[INSTALL_FOLDER]\IBM\SPSS\DataCollection\<version>\ SharedContent
Desktop products, such as UNICOM Intelligence Interviewer - Offline for Windows, UNICOM Intelligence Author, and UNICOM Intelligence Professional, will use the above location as a prefix when referencing files specified in <mrSharedRef>. For example,
<mrSharedRef RefPosition="head" RefType="script" type="text/javascript" src="Dojo//dojo/dojo.js" djConfig="parseOnLoad: true">
Dojo script</mrSharedRef>
will be rendered in UNICOM Intelligence Professional as:
<script type="text/javascript" src="C:\Documents and Settings\All Users\Application Data\IBM\SPSS\DataCollection\7\
SharedContent/Dojo/dojo/dojo.js" djConfig="parseOnLoad: true">Dojo script</script>
For server products, such as UNICOM Intelligence Interviewer - Server and UNICOM Intelligence Author Server Edition, the same tag might be rendered and loaded from the shared content area using the ImageCache. For example:
<script type="text/javascript" src="Images/Dojo/dojo/dojo.js" djConfig="parseOnLoad: true">Dojo script</script>
In addition, when referring to Javascript frameworks like Dojo, you can update the examples to use hard-coded links from a content delivery network. For example:
< script type="text/javascript"
src=" http://ajax.googleapis.com/ajax/libs/dojo/1.5/dojo/dojo.xd.js"
djConfig="parseOnLoad: true">
jQuery HTML control example
The jQuery HTML Control example demonstrates HTML controls built with the jQuery JavaScript library.
For information on installing jQuery, see Readme.htm file that is installed with the UNICOM Intelligence Developer Documentation Library at [INSTALL_FOLDER]\IBM\SPSS\DataCollection\7\DDL\Scripts\Interview\HTML Controls\jQuery.
See also
Writing templates