Global variables

The global variable allows you to print simple information such as the site’s name or the page the user is viewing in the design.

The format of the global variable is shown:

<MySource_PRINT id_name="__global__" var="<variable_name>" />

<variable_name> is the variable to print within the design. The available variables are outlined here.

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 following examples:

<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. This header forces an asset to be downloaded instead of being viewed on the screen. The file’s name 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" />

By default, this variable will print the relative URL of the site the user is currently viewing. This URL 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 name 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 variable will print the short name of the asset the user is currently viewing.

<MySource_PRINT id_name="__global__" var="asset_short_name" />

By default, this variable will print the relative URL of the asset the user is currently viewing. This URL 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 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 following code, 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 asset’s short name or ID to print the asset’s ID.

<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 signed in. By default, it will print the user’s full name (that is, the first and last name). If a user is not signed 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 following code, asset_name is used to print the user’s full name.

<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 user’s first name, or last_name to print the user’s last name.

<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 signed in, for example: Not signed in.

<MySource_PRINT id_name="__global__" var="current_user" default="Not signed in" />

file_path

This variable will print the path of an associated file (a file that has been uploaded to the design). It can be used if the system does not automatically parse the reference to the file in the parse file. For example, in inline JavaScript, the parse will not pick up the mysource_files path, so you need to explicitly specify the path.

<script language="JavaScript">
  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>

The filename argument is the name of the associated file that you want to use.

css_path

This variable will print the path to a CSS file uploaded as an associated file (that is, a file 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

The following is an example of the HTML code 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:

<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 Matrix image alt tag will be the name of the site.

© 2015- Squiz Pty Ltd