Core Tags

As of March 2017, Branch Code is deprecated and no longer developed. Use the Twig syntax instead.

Where can tags be used?

Core tags can be used just about anywhere in the site.  They can be used in Templates, Snippets, Navigation Menu Templates and in Page Content Layouts, Page Content Snippets and app content templates.

Header Tags

These tags will go in the head (<head></head>) section of the template HTML.

Tag Description
{ap_template:title} Gets the entire title tag along with the title text.
Result: <title>My Title Text</title>
{ap_template:titleText} Gets just the title text. Use in between the <title></title> tags.
Usage: <title>{ap_template:titleText}</title>
Result: <title>My Title Text</title>
{ap_template:css} Gets any links to style sheets or inline styles set by a module.
Result: <link href="/link/to/stylesheet.css" rel="stylesheet" type="text/css" />
{ap_template:head} Gets any miscellaneous information to be placed in the <head></head> section of the HTML.
{ap_template:javascript} Gets any links to javascript files or inline javascript set by a module.
Result: <script type="text/javascript" src="/path/to/javascript.js"></script>
{ap_template:meta} Gets any meta tags set by a content page or a module. This is typically used to pull in the description and keywords meta tags set by an app.
Results: Any meta tag.
{ap_template:doctype} Gets the doctype.
The doctype comes from the doctype set for the template.
Result:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
{ap_template:doctype includeHtmlTag="true"} Gets the doctype and the <html> tag.
This is useful for the XHTML doctypes and the <html> tag requires the "xmlns" attribute.
The doctype comes from the doctype set for the template.
Result:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
{ap_template:style} Gets any inline CSS styles set by a module.
Result: <style type="text/css>STYLES HERE</style>

Content Tags

There are a couple of variations of the content tag. The first one is a shortcut tag to just get the main content block. The next two are the exact same in functionality, just their syntax is different.

Tag Description
{ap_content} Gets the main content block.
{ap_content:blockName} Gets the content block specified by 'blockName'.

Inline Javascript Tag

This tag can be used to pull in any inline javascript that should be set within the body of the page.

Tag Description
{ap_template:inlineScript} Gets any inline javascript set by a module to set within the page body.

Navigation Tag

This tag is used to get a particular navigation menu.

Tag Description
{ap_navigation:menuKey} Gets the navigation menu specified by 'menuKey'.

Snippet Tag

Tag Description
{ap_snippet:snippetKey} Gets the snippet specified by the 'snippetKey'.

Container Tag

This tag is used to get the content for a specific container.

Tag Description
{ap_template:container key="containerKey"} Gets the content for the container specified by 'containerKey'.

Breadcrumb Trail Tags

Tag Description
{ap_template:breadcrumb}

Gets the breadcrumb trail for the page.


Options:
startDepth: Integer - Holds the zero-based depth of the breadcrumb array to start at. For example, to always skip the first item in the breadcrumb (i.e. the home page) set it to 1. Defaults to 0.
maxNumItems: Integer - Holds the maximum number of the breadcrumb items to show. For example, to only use the first two items set it to 2. If set to 0 then there is not a maximum number. This is applied after startDepth is applied. Defaults to 0 to allow all items.

Example:
{ap_template:breadcrumb startDepth="1" maxNumItems="3"} 

The above tag will start at the second item in the breadcrumb trail and will include 3 items.

{ap_template:breadcrumbText} Gets only the breadcrumb trail text for the current page.

Variable Tags

Variables are meant to hold values set by a module that can be displayed in a page. They are designated by the following format: {#variableName} where 'variableName' is the actual name of the variable. Below are some of the core variable tags that can be used.

Tag Description
{#body} Catch-all tag for the ID, Class and Onload attributes for the <body> tag. This can be used instead of {#bodyId}, {#bodyClass} and {#bodyOnload} as all of those variable values are contained in this one tag.
Usage: <body{#body}>
{#bodyIdValue} Gets the id text for the <body> tag. This would be used when it's known that the <body> tag will always have an id.
Usage: <body id="{#bodyIdValue}">
{#bodyId} Gets the id attribute for the <body> tag. This would be used when it's NOT known that the <body> tag will always have an id.
Usage: <body{#bodyId}>
Results: <body id="bodyID"> or <body>
{#bodyClassValue} Gets the class text for the <body> tag. This would be used when it's known that the <body> tag will always have at least one class.
Usage: <body class="{#bodyClassValue}">
{#bodyClass} Gets the class attribute for the <body> tag. This would be used when it's NOT known that the <body> tag will always have at least one class.
Usage: <body{#bodyClass}>
Result: <body class="className"> or <body>
{#bodyOnloadValue} Gets the Javascript for the onload attribute for the <body> tag. This would be used when it's known that the <body> tag will always have an onload event.
Usage: Usage: <body onload="{#bodyOnloadValue}">
{#bodyOnload} Gets the onload attribute for the <body> tag. This would be used when it's NOT known that the <body> tag will always have an onload event.
Usage: <body{#bodyOnload}>
Result: <body onload="onloadEvent();"> or <body>

AP Tags

These are miscellaneous tags.

These tags can also be used in Content Templates for an app, Page Content Block Layouts, Form Templates, Navigation Templates, Widget Templates or just about anywhere.

Tag Description
{ap:redirect location="http://www.mysite.com"} Redirects to the given location

Required Option:
location: The URL to redirect to

Optional Option:
status: The HTTP status code. Defaults to 302. Allowed values are 301, 302, 303, or 304.
{ap:date format="format"} Shows the current date in the specified format.
See the Date Formats page for available date formats.
{ap:time format="format"} Shows the current time in the specified format.
See the Date Formats page for available time formats.
{ap:year} Gets the current full year (4 digits).
{ap:year format="format"} Gets the current year in the specified format.
See the Date Formats page for available year formats.
{ap:month} Gets the current full textual month. i.e. October
{ap:month format="format"} Gets the current month in the specified format.
See the Date Formats page for available month formats
{ap:day} Gets the current 2 digit day with leading zero.
{ap:day format="format"} Gets the current day in the specified format
See the Date Formats page for available day formats
{ap:hour} Gets the current 2 digit hour with leading zero.
{ap:hour format="format"} Gets the current hour in the specified format.
See the Date Formats page for available hour formats
{ap:minute} Gets the current 2 digit minute with leading zero.
{ap:second} Gets the current 2 digit second with leading zero.
{ap: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

{ap.pageUpdatedOnTimestamp format="M/d/Y"}

{ap: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

{ap.pageUpdatedOnTimestamp format="M/d/Y"}

{ap:setTitle}

Sets the value of the <title> tag for the page. This will override any existing title value.

Options:
value: The new page title value

Example:

{ap:setTitle value="New Page Title"}

{ap:appendTitle}

Appends some text to the <title> tag for the page. 

Options:
value: The value to add to the page title

Examples:

{ap:appendTitle value=" Stuff at the end"}

A real world example. The goal is that with paginated blog post pages to add the page number to the page title so that it is unique.

If the page title is originally "Blog Posts" after this code the page title will be "Blog Posts - Page 2" (assuming that the visitor is on page 2).

{ap:appendTitle value=" - Page "}
{ap:appendTitle value="{#pagination.current}"}

{ap:prependTitle}

Prepends some text the <title> tag for the page.

Options:
value: The value to add to the page title

Example:

{ap:prependTitle value="Stuff at the beginning "}

{ap:request}

Handles setting up and sending a GET or POST request to an external URL.

See AP Request Tags

AP Assign Tag

The ap_assign tag lets you create custom variables to use in Content Templates for an app, Page Content Block Layouts, Form Templates, Navigation Templates, Widget Templates, site Templates, Snippets or just about anywhere.

An example usage would be if you wanted to programatically set the bodyId variable.

{ap_assign bodyId=" id='new-body-id'"}

The tag can set multiple variables at one time. They just need to be setup as name => value pairs and separated by a space.

{ap_assign variable1="value1" variable2="value2" variable3="value3"}

The variables can then be used in any template, snippet, content, or whatever following the assignment tag. 

For example, if you were using the following assignment tag:

{ap_assign testVar="test value"}

then you can use

{#testVar}

to include that variable.

Quotes (single or double) can be used in the variable value, but they can't the be same type of quote that surrounds the value (same rule that HTML tag attributes have).

By default the variable won't overwrite an existing variable assignment of the same name. That can be changed by putting ":overwrite" immediately after "ap_assign". 

{ap_assign:overwrite bodyId=" id='new-body-id'"} 

This will make it so that if "bodyId" has already be setup and assigned it will be overwritten with the new value.

AP Request Tags

The AP Request tags allow you to submit a POST or GET* request to a URL.

A sample scenario is if you need to submit form information to a 3rd party as well as save it within the CMS. In that case you can setup a Custom Process Script for the form to build the data to send and submit it to a URL as a POST submission.

* Right now no data is returned from the request so the GET request isn't very useful

Example

Below is a small example to post some XML to a URL

{#xml|set value="<?xml version='1.0' encoding='utf-8' ?>"}
{#xml|append value="<Data>"}
{#xml|append value="<Name>Bob Test</Name>"}
{#xml|append value="</Data>"}

{ap:request:new url="http://posttestserver.com/post.php"}
{ap:request:setBody body="{#xml}" encoding="text/xml"}
{ap:request:post}

Tags

Below are the available request tags.

Tag Description
{ap:request:new url="URL"}

Creates a new request object.

Optional Option

url: The full URL to submit the request to. If this is not set here then it needs to be set within {ap:request:setUrl}

Example

{ap:request:new url="http://posttestserver.com/post.php"}

{ap:request:setUrl url="URL"}

Sets the URL for the request object

Required Option

url: The full URL to submit the request to. If this is not set here then it needs to be set within {ap:request:setUrl}

Example

{ap:request:setUrl url="http://posttestserver.com/post.php"}

{ap:request:setHeader name="NAME" value="VALUE"}

Sets the header for the request

Required Options

name The name of the header
value The value for the header

Example

{ap:request:setHeader name="Content-type" value="text/html; charset=utf-8"}

{ap:request:setAuthentication username="X" password="Y"}

Sets the basic authentication credentials for the request.

Required Options

username The authentication username
password The authentication password

Example

{ap:request:setAuthentication username="aptuitiv" password="abc123"}

{ap:request:setBody body="BODY" encoding="TYPE"}

Sets the body for the request.

Required option

body The request body to set

Optional option

encoding The encoding type for the body

Example

{ap:request:setBody body="{#xml}" encoding="text/xml"}

{ap:request:setGetParameter name="NAME" value="VALUE"}

Sets a single GET parameter.

Required options

name The name of the parameter
value The value for the parameter

Example

{ap:request:setGetParameter name="paramName" value="paramValue"}

{ap:request:setPostParameter name="NAME" value="VALUE"}

Sets a single POST parameter.

Required options

name The name of the parameter
value The value for the parameter

Example

{ap:request:setPostParameter name="paramName" value="paramValue"}

{ap:request:send method="post"}

Sends the request using the specified method.

Required option

method The type of request

Optional option

saveAs

The name of the variable to save the response data to.

The data that is saved will be an array of the response information.  Below is an example

array(
    'body' => 'Response body here'
    'code' => '200',
    'codeMessage' => 'OK',
    'headers' => array(
        'Content-type' => 'application/json; charset=utf-8',
        'Content-length' => '149'
    )
)

Often API endpoints will return a JSON response. You can use the jsonDecode variable modifier to convert the JSON string to an array to work with.

Example

Send a POST request

{ap:request:send method="post"}

Send a GET request

{ap:request:send method="get"}

Send a POST request and save the response to a variable called "response". Assuming that the response is a JSON response convert the response body to an array that can be worked with.

{ap:request:send method="post" saveAs="response"}
{#response.body|jsonDecode}

{ap:request:post}

Sends the request as a POST request. This is shorthand for {ap:request:send method="post"}

Optional option

saveAs

The name of the variable to save the response data to.

The data that is saved will be an array of the response information.  Below is an example

array(
    'body' => 'Response body here'
    'code' => '200',
    'codeMessage' => 'OK',
    'headers' => array(
        'Content-type' => 'application/json; charset=utf-8',
        'Content-length' => '149'
    )
)

Often API endpoints will return a JSON response. You can use the jsonDecode variable modifier to convert the JSON string to an array to work with.

Example

{ap:request:post}

Send a POST request and save the response to a variable called "response". Assuming that the response is a JSON response convert the response body to an array that can be worked with.

{ap:request:post saveAs="response"}
{#response.body|jsonDecode}

{ap:request:get}

Sends the request as a GET request. This is shorthand for {ap:request:send method="get"}

Optional option

saveAs

The name of the variable to save the response data to.

The data that is saved will be an array of the response information.  Below is an example

array(
    'body' => 'Response body here'
    'code' => '200',
    'codeMessage' => 'OK',
    'headers' => array(
        'Content-type' => 'application/json; charset=utf-8',
        'Content-length' => '149'
    )
)

Often API endpoints will return a JSON response. You can use the jsonDecode variable modifier to convert the JSON string to an array to work with.

Example

{ap:request:get}

Send a GET request and save the response to a variable called "response". Assuming that the response is a JSON response convert the response body to an array that can be worked with.

{ap:request:get saveAs="response"}
{#response.body|jsonDecode}

{ap:request:getRequestData}  

Gets the request headers and request body information. This is intended to be used for debugging a request if you are having troubles.

It's intended that this is called after a request is made.

Required option

saveAs

The name of the variable to save the request data to.

The data that is saved will be an array of the request information.  

'headers' is the array of all of the headers with the header name as the array key and the value as the array value.

'rawHeaders' is all of the headers as a string.

'body' is the request body that was sent.

Below is a very minimal example

array(
    'headers' => array(
        'Host' => 'domain.com',
    )
    'rawHeaders' => 'Host: domain.com',
    'body' => 'Request Body Here'
)

Example

{ap:request:getRequestData saveAs="requestData"}
{#requestData|debug}

 {ap:request:getRequestBody}  

Gets the request body that was submitted. This is intended to be used for debugging a request if you are having troubles.

It's intended that this is called after a request is made.

Required option

saveAs

The name of the variable to save the request data to.

The data that is saved will be a string containing the request body that was sent. 

Example

{ap:request:getRequestBody saveAs="requestBody"}
{#requestBody|debug}

 {ap:request:getRequestHeaders}  

Gets the headers that were submitted with the request. This is intended to be used for debugging a request if you are having troubles.

It's intended that this is called after a request is made.

Required option

saveAs

The name of the variable to save the request data to.

The data that is saved will be an array of the request headers.  

'headers' is the array of all of the headers with the header name as the array key and the value as the array value.

'rawHeaders' is all of the headers as a string.

Below is a very minimal example

array(
    'headers' => array(
        'Host' => 'domain.com',
    )
    'rawHeaders' => 'Host: domain.com'
)

Example

{ap:request:getRequestHeaders saveAs="requestHeaders"}
{#requestHeaders|debug}