Global Variables
Last Updated: 17 Dec 2015
The global variable allows you to print simple information such as the name of the Site or the page the user is viewing in the design.
Bookmarks to the headings on this page:
The format of the global variable is shown below.
<MySource_PRINT id_name="__global__" var="<variable_name>" />
<variable_name> is the variable to print within the design. The variables that are available are outline below.
content_type
This variable will tell the browser what type of content to expect and accepts any MIME type. This variable can be used for RSS XML feeds, as shown in the examples below.
<MySource_PRINT id_name="__global__" var="content_type" content_type="application/rss+xml" />
<MySource_PRINT id_name="__global__" var="content_type" content_type="text/xml" />
content_attachment
This variable will add a "Content-Disposition: attachment" header to the design, thereby forcing an asset to be downloaded instead of being viewed on the screen. The name of the file will be the same as the asset name and the extension attribute specifies the file extension.
<MySource_PRINT id_name="__global__" var="content_attachment" extension="txt" />
site_link
By default, this variable will print the relative URL of the Site the user is currently viewing. This does not include the protocol or the fully qualified domain name.
<MySource_PRINT id_name="__global__" var="site_link" />The additional arguments that can also be used with this global variable are as follows:
- start_query_string: use this argument to add the specified query string to the new link. To use this argument, set this value to 1 and follow the statement with the appropriate query string.
- append_query_string: select whether to append the current query string (if any) to the link. By default, it is set to 0. Set this to 1 to append the query string.
- full_url: select whether to print the full URL (including the protocol and fully qualified domain name). By default, this is set to false. Set this to true to print the full URL.
<MySource_PRINT id_name="__global__" var="site_link" full_url="true" />
site_name
This variable will print the name of the Site the user is currently viewing. This comes from the Page Name field on the Site asset.
<MySource_PRINT id_name="__global__" var="site_name" />
assetid
This variable will print the id of the asset the user is currently viewing.
<MySource_PRINT id_name="__global__" var="assetid" />
asset_name
This variable will print the full name of the asset the user is currently viewing.
<MySource_PRINT id_name="__global__" var="asset_name" />
asset_short_name
This will print the short name of the asset the user is currently viewing
<MySource_PRINT id_name="__global__" var="asset_short_name" />
asset_link
By default, this variable this will print the relative URL of the asset the user is currently viewing. This does not include the protocol or the fully qualified domain name.
<MySource_PRINT id_name="__global__" var="asset_link" />The additional arguments that can also be used with this global variable are as follows:
- start_query_string: select whether to add the ? onto the end of the URL. If you are using a query string, you should set this to false.
<a href="<MySource_PRINT id_name="__global__" var="asset_link" start_query_string="false" />?queries_keyword_query=squiz">
Search for Squiz
</a> - append_query_string: select whether to append the current query string (if any) to the link. By default, it is set to false. Set this value to true to append the query string.
<MySource_PRINT id_name="__global__" var="asset_link" append_query_string="true" />
- clean_query_string: select whether to remove the query string from the link.
<a href="<MySource_PRINT id_name="__global__" var="asset_link" full_url="true" append_query_string="true" clean_query_string="true" />?SQ_DESIGN_NAME=printer_friendly" target="_blank">
Printer Friendly
</a> - full_url: select whether to print the full URL (including the protocol and fully qualified domain name). By default, this is set to false. Set this value to true to print the full URL.
<MySource_PRINT id_name="__global__" var="asset_link" full_url="true" />
current_asset
This variable will print information about the asset the user is currently viewing. By default, it will print the full name of the asset.
<MySource_PRINT id_name="__global__" var="current_asset" />Other information about the asset can be printed using the additional arguments. These arguments are as follows:
- keyword: enter a keyword replacement to specify what information to print from the asset. For example, in the code shown below, asset_url is used to print the full URL of the asset.
<MySource_PRINT id_name="__global__" var="current_asset" keyword="asset_url" />
- attr: enter which attribute to print from the asset. For example, you can enter short_name to print the short name of the asset or id to print the id of the asset.
<MySource_PRINT id_name="__global__" var="current_asset" attr="short_name" />
<MySource_PRINT id_name="__global__" var="current_asset" attr="id" />
current_user
This variable will print information about the user that is currently logged in. By default, it will print the full name of the user (i.e. the first and last name). If a user is not logged in, no information will be shown.
<MySource_PRINT id_name="__global__" var="current_user" />
- keyword: enter a keyword replacement to specify what information to print for the user. For example, in the code shown below, asset_name is used to print the full name of the user.
<MySource_PRINT id_name="__global__" var="current_user" keyword="asset_name" />
- attr: enter which attribute to print from the user account. For example, you can enter username to print the user’s username, first_name to print the first name of the user or last_name to print the last name of the user.
<MySource_PRINT id_name="__global__" var="current_user" attr="username" />
<MySource_PRINT id_name="__global__" var="current_user" attr="first_name" />
<MySource_PRINT id_name="__global__" var="current_user" attr="last_name" /> - default: enter the text to display when the user is not logged in, for example, Not logged in.
<MySource_PRINT id_name="__global__" var="current_user" default="Not logged in" />
file_path
This variable will print the path to an associated file (i.e. a file that has been uploaded to the Design). It can be used if the reference to the file in the parse file is not automatically parsed by the system. For example, in inline JavaScript, the parse will not pick up the mysource_files path, so you need to specify the path explicitly. An example is given below.
<script language="JavaScript">The filename argument is the name of the associated file that you want to use.
var img1on = new Image();
img1on.src = '<MySource_PRINT id_name="__global__" var="file_path" filename="image_on.gif" />';
var img1off = new Image();
img1off.src = '<MySource_PRINT id_name="__global__" var="file_path" filename="image_off.gif" />';
</script>
css_path
This variable will print the path to a css file that has been uploaded as an associated file (i.e. a file that has been uploaded to the Design).<MySource_PRINT id_name="__global__" var="css_path" filename="styles.css" />
asset_thumbnail
This variable will print the thumbnail that has been assigned to the asset.
<MySource_PRINT id_name="__global__" var="asset_thumbnail" />
asset_thumbnail_url
This variable will print the full URL of the thumbnail that has been assigned to the asset.
<MySource_PRINT id_name="__global__" var="asset_thumbnail_url" />
pragma
This variable will add an implementation pragma to the HTTP header of the design.
<MySource_PRINT id_name="__global__" var="pragma" content_type="no_cache" />
Example
Below is the HTML code that was added to the static HTML file to show where the global variables should go in the design
<head>
<!-- Global Variables -->
The required code is added to the parse file for the global variables, as shown below.
<head>
<title>
<MySource_PRINT id_name="__global__" var="site_name" /> - <MySource_PRINT id_name="__global__" var="asset_name" />
</title>
The name of the site will appear in the title of the page, the name of the page will appear in the bar across the top of the design and the Squiz Matrix image alt tag will be the name of the site.