Body tag attributes

When you're editing a page you can set a specific classid, or onload attribute value. Use the {{ _page.body }} object to access those values.

Below are the tags to output the body tag attributes.

 
Tag Description
_page.body.attributes

The full attributes string for the body tag.

<body{{ _page.body.attributes() }}>

If there are any attributes then a space will be added to the beginning of the attributes

_page.body.class

{{ _page.body.class }}> " style="border-bottom-width: ; border-bottom-style: ; border-color: var(--color-blue-650);">

Outputs just the class attribute value if there is one.

<body class="{{ _page.body.class }}">

_page.body.class.attr

Outputs the entire class attribute if an attribute value exists. If there is no attribute value then nothing is outputted.

<body{{ _page.body.class.attr }}>

_page.body.id

Outputs the entire class attribute if an attribute value exists. If there is no attribute value then nothing is outputted.

<body{{ _page.body.class.attr }}>

_page.body.id

Outputs just the id attribute value if there is one.

<body id="{{ _page.body.id }}">

_page.body.id.attr

Outputs the entire id attribute if an attribute value exists. If there is no attribute value then nothing is outputted.

<body{{ _page.body.id.attr }}>

_page.body.onload

Outputs just the onload attribute value if there is one.

<body class="{{ _page.body.onload }}">

_page.body.onload.attr

Outputs the entire id attribute if an attribute value exists. If there is no attribute value then nothing is outputted.

<body{{ _page.body.onload.attr }}>

_page.body.tag

Outputs the whole <body> tag along with any attributes.

Setting body tag attributes

If you want to use the {{ _page.body }} object to hold body tag attributes then you can also set attributes. The <body> tag attributes that you set are not limited to the classbody, or onload attributes.

You just have to set the values before you use them in your template.

Below are some different examples of setting values. 

 
{% set _page.body.class = 'myClassValue' %}

{# Append a value to the existing class value if there is one #}
{% set _page.body.class = _page.body.class ~ ' anotherClassValue' %}

{% set _page.body.id = 'idValue' %}
{% set _page.body.onload = 'codeToRun();' %}

{# Set a custom attribute #}
{% set _page.body.onunload = 'unloadFunction()' %}

{# Access just a custom attribute #}
<body{{ _page.body.onunload.attr }}>
<body onunload="{{ _page.body.onunload }}">
This documentation is only for Aptuitiv CMS. Learn more.
Get Started With Aptuitiv