Global Variables
As of March 2017, Branch Code is deprecated and no longer developed. Use the Twig syntax instead.
Global Variables are variables that are available on every app Content Template, Navigation Template, Collection Widget Template, Page Content Layout Templates, and Page Content Snippets.
They are accessed under the {#global} variable.
Note, this means that you shouldn't create any Attributes with a layout key of "global" otherwise the value for that Attribute will be overridden by the Global Variable.
Variable Types
General Variables
Tag | Description |
---|---|
{#global.pageTitle} |
Holds the page title for the current page being viewed on the public website. Type: String Example: Simply use the tag as is: {#global.pageTitle} |
{#global.pageUpdatedOnTimestamp} |
Holds the timestamp for when the newest element on the page was updated. Any of the components on the page could affect this value. Typical items that could affect this date is navigation items, navigation templates, templates, snippets, page content, app item content, and content templates. Type: Integer Optional Options: format: The date format to display the timestamp as. See the Date Formats page for available date formats. Example: Output the date as Month/Day/Year {#global.pageUpdatedOnTimestamp format="M/d/Y"} |
{#global.updatedOnTimestamp} | Holds the last modified timestamp for the item that is the focus of the page. That item could be Page content, a Blog post, a Gallery item, a Store category or another app item.
Type: Integer Optional Options: format: The date format to display the timestamp as. See the Date Formats page for available date formats. Example: Output the date as Month/Day/Year {#global.updatedOnTimestamp format="M/d/Y"} |
Account Variables
These variables are used to work with public user accounts. For other Account values use the Account API.
Tag | Description |
---|---|
{#global.loginUrl} |
Holds the URL to log into a public account. Type: String |
{#global.logoutUrl} |
Holds the URL to log out of a public account. Type: String |
{#global.user.isLoggedIn} |
Holds whether or not the current public user is logged in. Type: Boolean |
Cookie Variable
The cookie variable holds any cookies on the public website for you to use in your site logic.
You would use Javascript to set the cookie (See http://www.w3schools.com/js/js_cookies.asp for a tutorial). On subsequent page loads for that user the cookie value would then be available in the {#global.cookies} array.
For example, if you create a cookie named "myCookie" with a value of "cookieValue" with Javascript then the next time the user visits another page in the website you can access the "myCookie" value at {#global.cookies.myCookie}.
Tag | Description |
---|---|
{#global.cookies} |
Holds any cookies on the public website. Type: Array |
Date Variables
These variables are used to work with the current date.
Tag | Description |
---|---|
{#global.date.day} |
Holds the current day date with leading zeros. Type: Integer Example value: 14 or 09 |
{#global.date.dayShort} |
Holds the current day date with no leading zeros. Type: Integer Example value: 14 or 9 |
{#global.date.isWeekend} |
Holds whether or not the current day is a weekend day Type: Boolean |
{#global.date.monthName} |
Holds the full month name for the current month. Type: String Example value: October |
{#global.date.monthNameShort} |
Holds the abbreviated month name for the current month. Type: String Example value: Oct |
{#global.date.monthNumber} |
Holds the current month number with leading zeros. Type: Integer Example value: 10 or 05 |
{#global.date.monthNumberShort} |
Holds the current month number with no leading zeros. Type: Integer Example value: 10 or 5 |
{#global.date.weekOfMonth} |
Holds the week number of the current week in the current month Type: Integer Example value: 2 |
{#global.date.weekday} |
Holds the full weekday name for the current day. Type: String Example value: Thursday |
{#global.date.weekdayAbbr} |
Holds the abbreviated weekday name for the current day. Type: String Example value: Thu |
{#global.date.weekdayLetter} |
Holds the single letter for the weekday name for the current day. Type: String Example value: T |
{#global.date.weekdayNumber} |
Holds the weekday number for the current day. Type: Integer Example value: 5 |
{#global.date.weekdayShort} |
Holds the abbreviated weekday name for the current day. Usually 2 or 3 letters. Type: String Example value: Thu or Fri |
{#global.date.year} |
Holds the 4 digit year for the current year. Type: Integer Example value: 2013 |
{#global.date.yearShort} |
Holds the 2 digit year for the current year. Type: Integer Example value: 10 |
Time Variables
These variables are used to work with the current time.
Tag | Description |
---|---|
{#global.time.ampm} |
Holds Uppercase Ante meridian and Post meridian. Type: String Example value: AM or PM |
{#global.time.hour} |
Holds the 24-hour format of an hour with leading zeros. Type: Integer Example value: 08 or 15 |
{#global.time.hour12} |
Holds the 12-hour format of an hour with leading zeros. Type: Integer Example value: 08 or 11 |
{#global.time.hourShort} |
Holds the 24-hour format of an hour with no leading zeros. Type: Integer Example value: 8 or 15 |
{#global.time.hourShort12} |
Holds the 12-hour format of an hour with no leading zeros. Type: Integer Example value: 8 or 11 |
{#global.time.military} |
Holds the full military time with the hour and minute with leading zeros. Type: Integer Example value: 0930 or 1415 |
{#global.time.minute} |
Holds the minute with leading zeros. Type: Integer Example value: 05 or 32 |
{#global.time.minuteShort} |
Holds the minute with no leading zeros. Type: Integer Example value: 5 or 32 |
{#global.time.second} |
Holds the second with leading zeros. Type: Integer Example value: 02 or 45 |
{#global.time.secondShort} |
Holds the second with no leading zeros. Type: Integer Example value: 02 or 45 |
{#global.timestamp} |
Holds the current Unix timestamp. Type: Integer Example: You can use this tag to output the current date or type by using the date variable modifier. {#global.timestamp|date format="M d, Y"} That will output the current date as "Jan 01, 2013". |
App Page Data
These variables give you information about the current app page that is being viewed.
A few example usages include:
- Using in other app content templates, particularly API content templates to get an idea of what content is being displayed.
- Forms integrate app data into a form.
Note that if you are on a regular page then this information will not be available because you are not on an app page.
Tag | Description |
---|---|
{#global.appData.category} |
Holds the data for the category being viewed. This could be set when viewing a category detail page or when viewing an app item detail page. If it's set when viewing an app item detail page then it will be in reference to the category that the app item is assigned to. If the visitor came from a category page before coming to the item detail page (and the app item is assigned to that category) then the information for that category will be set. If the visitor did not come from a category detail page first and the app item has at least one category, then the first category in the item 'categories' array will be used to set this data. Type: Array |
{#global.appData.item} |
Holds the data for the app item being viewed. Type: Array |
{#global.appData.pageType} |
Holds the type of page being viewed. Examples values include (but are not limited to):
Type: String |
{#global.appData.tag} |
Holds the data for the tag being viewed. Type: Array |
{#global.appData.urls} |
Holds the core URLs for the app. Example URLs could include:
Type: Array |
IP GeoLocation Variables
These variables give you the geolocation information for the visitor based on their IP address.
Because the information is based on the IP address it is not 100% accurate, but it is usually close. The way that their Internet Service Provider handles their IP addresses and their network can affect the accurateness of the information.
Accuracy will be about 99.8% accurate on a country level, 90% accurate on a state level, 81% accurate on a city level for the US within a 25 mile radius.
NOTE: This information is only available on Plus or higher plans.
Tag | Description |
---|---|
{#global.geo.city} |
Holds the name of the city of the visitor. Type: String |
{#global.geo.country} |
Holds the full name of the country of the visitor. Type: String |
{#global.geo.countryCode} |
Holds the 2 character abbreviation of the country of the visitor. Type: String |
{#global.geo.latitude} |
Holds the approximate latitude of the visitor. Type: String |
{#global.geo.longitude} |
Holds the approximate longitude of the visitor. Type: String |
{#global.geo.region} |
Holds the full name of the region (state / province) of the visitor. Type: String |
{#global.geo.regionCode} |
Holds the 2 character abbreviation of the region (city / province) of the visitor. Type: String |
Mobile Variables
These variables give you information about the mobile device being used to view the page.
NOTE: This information is only available on Plus or higher plans.
Tag | Description |
---|---|
{#global.mobile.isEnabled} |
Holds whether or not mobile detection is available or enabled for the website. Type: Boolean |
{#global.mobile.isMobile} |
Holds whether or not the device viewing the website is a mobile device. Type: Boolean |
Request Parameter Variables
These variables allow you to access any GET or POST request parameters. It also contains some other information about the request.
Tag | Description |
---|---|
{#global.request.get} |
Holds any query parameters in the URL. These are anything after the ? in the URL. These are also know as GET request parameters. Type: Array Example: Example URL: http://www.mysite.com/page?msg=hello With the above URL the "msg" parameter would be available as {#global.request.get.msg} and that tag would output "hello". |
{#global.request.ip} |
Holds the IP address of the visitor. Type: String |
{#global.request.post} |
Holds any POST parameters. These values would be the result of a form submitted. Type: Array Example: {#global.request.post.parameter-name} where "parameter-name" is the name of the form field that was submitted. |
{#global.request.url} |
Holds the URL for the current page being viewed on the public website. It does contain any URL parameters. It does not contain the domain name. Type: String Example: Simply use the tag as is: {#global.request.url} |