Global Keywords

Global keyword replacements can be used within various assets in the system to show different information about the current asset the user is viewing, the current site they are viewing or their user account if they are logged in. For example, to show the name of the page the user is currently viewing as a heading in your Design, you can use the global keyword replacement %globals_asset_name%.

Site

The format of the global keyword replacement for a Site is:

%globals_site_<attribute>%

where <attribute> is any attribute available on the Site. For example, %globals_site_name% shows the name of the Site the user is currently viewing. This global keyword replacement  could then be used in a Design to show the name of the Site. If the name of the Site then changes, the Design will not need to be updated, as the global keyword replacement will source the information directly from the Site.

Asset

The format of the global keyword replacement for an asset is:

%globals_asset_attribute_<attribute>%

where <attribute> is any attribute available on the asset. For example, %globals_asset_attribute_title% shows the Title attribute of a File type asset the user is currently viewing. This global keyword replacement could then be used in a Design to show the title of the asset. If the title of the asset then changes, the Design will not need to be updated, as the global keyword replacement will source the information directly from the asset.

The global keyword replacement system also allows you to use keyword replacements for a specific asset within other assets in the system. The format of this global keyword replacement is:

%globals_asset_attribute_<attribute>:<assetid>% 

where <attribute> is the attribute that you want to show for the asset and the <assetid> is the ID of the asset you want to reference. For example, we have an Image asset in our system with an asset ID of #67. The global keyword %globals_asset_attribute_title:67% will show the title of this Image asset, while the global keyword %globals_asset_attribute_size:67% will show its file size. 

You can also show any metadata values on the asset by using the format:

%globals_asset_metadata_<fieldname>%

where <fieldname> is the name of the metadata field you want to show. For example, if you have a Description metadata field on your asset, %globals_asset_metadata_Description% will show the value of this field.

You can also specify an asset ID on this keyword replacement to show metadata values of other assets within the system. The format of this global keyword replacement is:

%globals_asset_metadata_<fieldname>:<assetid>% 

where <fieldname> is the name of the metadata field you want to show for the asset and <assetid> is the ID of the asset you want to reference. For example, %globals_asset_metadata_Description:100% will show the Description metadata value on asset #100.

Global Asset Shortcuts

A handful of commonly used global keyword replacements employ an abbreviated format. For more information on the common keyword replacements that can be used as global keyword replacement shortcuts, refer to the Common Keywords chapter in this manual.

The asset global keyword replacement shortcuts available include:

%globals_asset_assetid%
%globals_asset_name%
%globals_asset_name_linked%
%globals_asset_short_name%
%globals_asset_type%
%globals_asset_type_icon%
%globals_asset_contents% %globals_asset_url% %globals_asset_href%
%globals_asset_created%
%globals_asset_updated%
%globals_asset_published%

The global keyword replacement:

%globals_asset_charset%

will show the character set for the asset and the global keyword replacement:

%globals_asset_languages%

will show what language the asset has been set to. These values can be found on the Settings screen of an asset.

User

If an asset is going to be viewed by a user who is logged into your Site, you can personalise the content through the use of global keyword replacements. For example, if the page you are creating can only be viewed by a member of your Site who has logged in, then you can personalise the page with the member's details, such as their name. The format of the global keyword replacement is:

%globals_user_attribute_<attribute>%

where <attribute> is any attribute available on the user account. Some examples include %globals_user_attribute_first_name% which prints the first name of the user and %globals_user_attribute_email% which prints the email address of the User asset.

You can also show any metadata values from the user account by using the format:

%globals_user_metadata_<fieldname>%

where <fieldname> is the name of the metadata field you want to show. For example, if you have applied a Metadata Schema to a user account that contains the field Hobbies, you can show the value that has been entered into this field by using the global keyword replacement %globals_user_metadata_Hobbies%. You can place these keyword replacements within the content of an asset. Squiz Matrix will then replace these keyword replacements with the correct information from the user account.

Server Variable

The format of the global keyword replacement for the web server is:

%globals_server_<variable>%

where <variable> is the PHP session variable that you want to return server information from (ref: PHP $_SERVER Manual). For example, the global keyword replacement %globals_server_http_user_agent% will return the header of the current request (e.g. Mozilla/4.5 [en] (X11; U;Linux 2.2.9 i586 ) ).

Please note that the server information available will vary depending on the setup of your web server.

Session Variable

The format of the global keyword replacement for a session is:

%globals_session_<variable>%

where <variable> is the name of the item you want to access in the Squiz Matrix session sandbox. This global keyword replacement can be used in conjunction with Triggers. For example, in a Trigger, you can set a session variable and then access it via this global keyword replacement. For more information about Triggers, refer to the Triggers manual.

HTTP GET Variable

The format of the global keyword replacement for a HTTP GET variable is:

%globals_get_<variable>%

where <variable> is the name of the variable that you want to access. Only scalar variables can be used as global keyword replacements. Arrays are not supported.

HTTP POST Variable

The format of the global keyword replacement for a HTTP POST variable is:

%globals_post_<variable>%

where <variable> is the name of the variable that you want to access. Arrays are not supported.

Current Date and Time

The global keyword replacement:

%globals_date%

will display the current server date and time, for example, 6th Feb 2009 5:00pm. This global keyword replacement can be suffixed with a PHP date format (ref: PHP: Date Manual) for greater control of the date and time that is displayed. For example, if you use the global keyword replacements %globals_date_M%%globals_date_Y%, it will show Feb 2009.

Current Context

The global keyword replacement:

%globals_context% 

will display the current context the user is viewing. For more information on contexts, refer to the Contexts manual.

Random Number Generation

The global keyword replacement:

%globals_random% 

will generate a random number. This global keyword replacement can be configured to generate a number within a set range of integers by using the format %globals_random_<MIN>_<MAX>%. For example, the global keyword replacement %globals_random_1_6%, where 1 is the minimum number and 6 is the maximum, will generate a number within that 1 to 6 range.

The format of the global keyword replacement for a cookie is:

%globals_cookie_<variable>%

where <variable> is the name of the cookie you want to display the value of. This global keyword replacement can be used in conjunction with Triggers. For example, in the Set Cookie Trigger action you can set the cookie name and value and then access it via this global keyword replacement. For more information about Triggers, refer to the Triggers manual.

Asset Map Icons

The format of the global keyword replacement to display the Asset Map icon of an asset is:

%globals_icon_<type>%

where <type> is the asset type of the icon you want to display. For example, %globals_icon_page_standard% will display the Asset Map icon of the Standard Page asset type.

Site Special Pages

The global keyword replacements:

%globals_site_index_id%
%globals_site_not_found_id%
%globals_site_archive_id% 

will display the asset ID of a Site Special Page (The configured IndexNot Found and Archived Asset pages of a Site).

An asset ID of a Site can be appended to these global keyword replacements to specify the Site to return the asset ID values from. For example, the global keyword replacement:

%globals_site_index_id:100%

Will return the asset ID of the Index page of the Site with the asset ID of 100.