Objects

Objects contain attributes that you can call in theme files. These attributes are mostly set by you (content fields), and filled with a value by the user. To call the object’s attribute, (E.g. a post’s title) you call it like a variable (wrapped in {{ and }}).

Input:

{{ post.title }}

Output:

This is a great post!

In the list below you’ll find documentation on the object’s default attributes. But after adding a content field, the resulting attributes are called in the same way.


attachment

The attachment object is returned when an attribute of a media field is called. E.g. {{ post.featured_image }} (when featured_image is a media field) returns an attachment object.

attachment.crop

Returns the crop values of the attachment if it’s an image. The values are: left, top, width, height. By default the left and top are set to 0, and width and height to 100% of the image size, i.e. no crop. The attachment’s crop values can be changed by enabling inline crop in the img_tag filter.

Input:

{{ attachment.crop }}

Output (no crop):

0,0,450,360

Output (horizontal crop):

0,100,450,200

Output (vertical crop):

120,0,300,360

You can use the crop values in the img_url filter like this:

{{ attachment | img_url: 600, crop: attachment.crop }}

attachment.src

Returns the original url of the attachment.

Input:

{{ post.featured_image.src }}

Output:

https://plate-attachments.s3.amazonaws.com/images/12ab34cd56/featured-image-path.png

attachment.meta

Returns an object with the attachment’s meta information, i.e. file mime type, file size, image dimensions if attachment is an image, etc.

Input:

{{ attachment.meta }}
{{ attachment.meta.is_image }}
{{ attachment.meta.file_size }}
{{ attachment.meta.height }} x {{ attachment.meta.width }}

Output:

{"mime_type" => "image/jpeg", "file_size" => 12345, "ext" => "jpeg", "format" => "jpg"...
true
12345
450 x 360

The meta object has the following attributes for all files:

When the attachment is an image, it has the following attributes as well:

attachment.file_name

Returns the file’s name, the part of the src url that represents the file.

Input:

{{ post.featured_image.file_name }}

Output:

featured-image-path.png

Breadcrumbs allows you to iterate through the Post tree structure, from root up to the current post. It can help the site’s visitor to navigate ‘up’ from the current post in the site. The breadcrumbs object is an array filled with objects representing each post ‘above’ the current post, including the current post. Each object in the breadcrumbs array contains a title and a url attribute.

Input:

{% for breadcrumb in breadcrumbs %}
  <a href="{{breadcrumb.url}}">{{breadcrumb.title}}</a>
  {% unless forloop.last %} | {% endunless %}
{% endfor %}

Output:

<a href="/">Home</a> |
<a href="/blogposts">Blogposts</a> |
<a href="/blogposts/news-message">News Message</a>

column

The column object is accessible in the columns/_column.plate theme file, if it’s rendered by the {% render_content %} tag inside the {% content_for row %} block. Read more on how content_for works here.

column.elements

Returns array of elements that have the column object as parent.

{{ column.elements }}

column.viewport_options

Returns an object with the column’s viewport options. De available options are:

Input:

{{ column.viewport_options.avg_image_width }}

Output:

[360, 354, 466, 570]

Input (call for md viewport):

{{ column.viewport_options.xs.avg_image_width }}
{{ column.viewport_options.md.avg_image_width }}

Output:

360
466

If the viewport breakpoint is < 768px it is assumed the viewport is intended for mobile devices. In this case avg_image_width returns 360, since most mobile devices are not wider than 360px.


content_type

The type object is accessible for Plate objects that have content types, element and post.

content_type.name

Returns the name of the content type.

{{ project.content_type.name }}
project

content_type.title

Returns the title of the content type.

{{ social_media_button.content_type.title }}
Social Media Button

element

The element object is accessible in the elements/_element.plate theme file, if it’s rendered by the {% render_content %} tag inside the {% content_for column %} block. Read more on how content_for works here.

The elements/_element.plate usually calls the {% content_for element %} block, which renders the :plural_element_type_name/_singular_element_type.plate theme file, with access to the same element object. However, in this case calling the singular content type name returns the element object.

So,
calling {{ element }} in elements/_element.plate returns the element object, and
calling {{ social_media_button }} in social_media_buttons/_social_media_button.plate returns the same element object.

element.content_type

Returns content_ype object.


post

Calling the post object returns the current post. Calling the post’s singular content type name (E.g. ‘category’) also returns the post object. So both {{ post }} and {{ category }} return the same post in this case.

post.sections

Returns array of sections that have the post object as parent.

{{ post.sections }}

post.title

Returns post title.

post.slug

Returns post slug, the part of the URL that identifies the post.

Input:

{{ post.slug }}

Output:

this-is-a-great-post

post.published_at

The post’s publish date and time.

post.url

The post url.

Input:

{{ category.url }}

Output:

/categories/mighty-fine-category

post.seo_title

Returns post SEO title.

post.seo_description

Returns post SEO description.

post.content_type

Returns content_type object.

post.parent

Returns parent, if there is a parent set in the Post settings.

post.translations

Returns an array of translations of the Post. Can be empty.


request

The request object has attributes of the current state of the web page.

request.fullpath

Returns full path, include query string.

Input:

{{ request.fullpath }}

Output:

/this/is-a/path?full=1

request.path

Returns only path, without query string.

Input:

{{ request.path }}

Output:

/this/is-a/path

request.query

Returns query string. Everything after ‘?’.

Input:

{{ request.query }}

Output:

full=1&page=5

request.query_object

Converts the query string into an object

Input:

{{ request.query_object }}

Output:

{"full" => "1", "page" => "5"}

Input:

{{ request.query_object.page }}

Output:

5

request.url

Returns the full current url.

Input:

{{ request.url }}

Output:

https://www.my-plate-site.com/this/is-a/path?full=1

request.flash

Contains browser flash messages like form errors.

Input:

{{ request.flash.alert }}
{% for error_msg in request.flash.errors %}
  - {{ error_msg }}
{% endfor %}

Output:

Something went wrong while sending the message.
- Name is required
- Email is invalid

row

The row object is accessible in the rows/_row.plate theme file, if it’s rendered by the {% render_content %} tag inside the {% content_for section %} block. Read more on how content_for works here.

row.columns

Returns array of columns that have the row object as parent.

{{ row.columns }}

section

The section object is accessible in the sections/_section.plate theme file, if it’s rendered by the {% render_content %} tag inside the {% content_for post %} block. Read more on how content_for works here.

section.rows

Returns array of rows that have the section object as parent.

{{ section.rows }}

section.name

Returns the section name


site

The site object is accessible everywhere. The site object has the following default attributes, but is also extendible by adding content fields.

site.name

Returns the site name

site.domain

Returns the site’s primary full domain. E.g. www.my-plate-site.com.

site.:plural_post_type_name

Returns all posts (objects with the specified post type). E.g. {{ site.pages }} returns all posts with the content type ‘page’. Adding _index returns the index post (the post with the index template). E.g. {{ site.pages_index }}.

site.languages

Returns an array of objects representing the available languages for the site.

Input:

{{ site.languages }}

Output:

[
  { "shortcode" => "nl", "name" => "Dutch, "url" => "/dutch-url" },
  { "shortcode" => "en", "name" => "English, "url" => "/en/english-url" },
  { "shortcode" => "de", "name" => "German, "url" => "/de/german-url" }
]

The url attribute returns the url of the translation for the Post you are on. If there is no translation found, the root url for the language is returned. E.g. ‘/en’ for English, ‘/fr’ for French, and so on.

Input:


{% for language in site.languages %}
  <a href="{{ language.url }}">{{ language.name }}</a>
{% endfor %}

Output:

<a href="/dutch-url">Dutch</a>
<a href="/en/english-url">English</a>
<a href="/de">German</a> <!-- uses root german url if no translation is found !>