Overview

The following information is intended for advanced users.

The Site object provides access to all the properties in the SDF file as well as some useful methods that make it easier to process template files.

The Site object is used frequently, and for that reason, Second Site provides the following two shortcuts:

  • You do not have to specify the object name when you refer to a Site object property or method. So, "Site.Wrapper" and "Wrapper" are synonymous.
  • Some of the most frequently used SDF file properties may be accessed through special properties rather than through the Item property. They are described below in the Shortcut Properties section.

For general instructions on using script statements, see the Script Usage page.

Properties

Item()

Item(property)

Returns the value of the specified property. The property parameter must include the section name and property name separated by a period as in "sectionName.propertyName".

Example

The compiler name is <%=Item("Compiler.Name")%>.

Shortcut Properties

Scripts should always use shortcut properties rather than their Item(...) equivalents. All of the shortcut properties are read-only; you may not set the value of the underlying property using the shortcut.

BuildDate

Same as Item("Build.Date").

BuildTime

Same as Item("Build.Time").

BuildCount

Same as Item("Build.Count").

Description

Same as Item("Site.Description").

SubTitle

Same as Item("Site.SubTitle").

Title

Same as Item("Site.Title").

Methods

GetTextOnly()

GetTextOnly(string)

Returns the text in string minus any HTML tags. Does not remove entity codes, e.g., does not remove &nbsp;, etc.

HiddenEMailURL()

Returns the Compiler's e-mail address hidden via the use of a javascript link in an HTML "A" tag.

Include()

Include(filepath)

Returns the contents of the specified file.

You may use a relative filepath, in which case the path is evaluated relative to the Input (-i) folder. You may also use an absolute filepath.

If you use the Include() function, I suggest that you create an include sub-folder in your Input (-i) folder. Second Site skips the include folder when copying files and folders to the Output (-o) folder. Putting files in the include folder means they will not be copied to the Output folder except as a result of Include() statements.

If you use backslashes in the filepath, you must double each backslash as shown in the examples below. Script statements are usually entered in User Item text or static content properties, and backslashes are given special treatment there.

Relative FilePath Examples

For the following examples, assume the Input folder is c:\ss\mysite-i\. Each example shows a function call and the resulting file path.

Call: Include("file.htm")
File: c:\ss\mysite-i\file.htm")
Call: Include("include\\file.htm")
File: c:\ss\mysite-i\include\file.htm")
Call: Include("..\\shared\\file.htm")
File: c:\ss\shared\file.htm")

InputFileExists()

InputFileExists(filename)

Returns true if a file with the specified filename exists in the Input (-i) folder.

OutputFileExists()

OutputFileExists(filename)

Returns true if a file with the specified filename exists in the Output (-o) folder.

Transform()

Transform(xml-filepath, xslt-filepath)

Transforms the XML file xml-filepath to HTML using the XSLT file xslt-filepath and returns the result.

It's convenient to store the XML and XSL files in the include folder:

Transform("include\\addresses.xml", "include\\addresses.xsl")

See the Transform() Function Example.

Wrapper()

Wrapper(prefix, value, suffix)

If value is empty, Wrapper returns an empty string. If value is not empty, Wrapper() returns the concatenation of the three arguments.

A common use of Wrapper() is to include HTML code around properties that may be empty. if the property is empty, Wrapper() suppresses the HTML code.

On This Page