Skip to content

Radiant Tag Reference

Daniel Myasnikov edited this page Jan 16, 2015 · 1 revision

<r:page>

Causes the tags referring to a page’s attributes to refer to the current page.

Usage

<r:page>...</r:page>

<r:breadcrumb>

Renders the breadcrumb attribute of the current page.

Usage

<r:breadcrumb/>

<r:slug>

Renders the slug attribute of the current page.

Usage

<r:slug/>

<r:title>

Renders the title attribute of the current page.

Usage

<r:title/>

<r:url>

Renders the URL attribute of the current page.

Usage

<r:url/>

<r:children>

Gives access to a page’s children.

Usage

<r:children>...</r:children>

<r:count>

Renders the total number of children.

Usage

<r:count/>

<r:children:first>

Returns the first child. Inside this tag all page attribute tags are mapped to
the first child. Takes the same ordering options as <r:children:each>.

Usage

<r:children:first>...</r:children:first>

<r:children:last>

Returns the last child. Inside this tag all page attribute tags are mapped to
the last child. Takes the same ordering options as <r:children:each>.

Usage

<r:children:last>...</r:children:last>

<r:children:each>

Cycles through each of the children. Inside this tag all page attribute tags
are mapped to the current child page. Note [offset] requires [limit].

Usage

<r:children:each [offset="number"] [limit="number"] [by="attribute"] [order="asc|desc"] [status="draft|reviewed|published|hidden|all"]>
  ...
</r:children:each>

<r:child>

Page attribute tags inside of this tag refer to the current child. This is occasionally
useful if you are inside of another tag (like <r:find>) and need to refer back to the
current child.

Usage

<r:children:each>
  <r:child>...</r:child>
</r:children:each>

<r:if_first>

Renders the tag contents only if the current page is the first child in the context of
a children:each tag

Usage

<r:children:each>
  <r:if_first >
    ...
  </r:if_first>
</r:children:each>

<r:unless_first>

Renders the tag contents unless the current page is the first child in the context of
a children:each tag

Usage

<r:children:each>
  <r:unless_first >
    ...
  </r:unless_first>
</r:children:each>

<r:if_last>

Renders the tag contents only if the current page is the last child in the context of
a children:each tag

Usage

<r:children:each>
  <r:if_last >
    ...
  </r:if_last>
</r:children:each>

<r:unless_last>

Renders the tag contents unless the current page is the last child in the context of
a children:each tag

Usage

<r:children:each>
  <r:unless_last >
    ...
  </r:unless_last>
</r:children:each>

<r:header>

Renders the tag contents only if the contents do not match the previous header. This
is extremely useful for rendering date headers for a list of child pages.

If you would like to use several header blocks you may use the name attribute to
name the header. When a header is named it will not restart until another header of
the same name is different.

Using the restart attribute you can cause other named headers to restart when the
present header changes. Simply specify the names of the other headers in a semicolon
separated list.

Usage

<r:children:each>
  <r:header [name="header_name"] [restart="name1[;name2;...]"]>
    ...
  </r:header>
</r:children:each>

<r:parent>

Page attribute tags inside this tag refer to the parent of the current page.

Usage

<r:parent>...</r:parent>

<r:if_parent>

Renders the contained elements only if the current contextual page has a parent, i.e.
is not the root page.

Usage

<r:if_parent>...</r:if_parent>

<r:unless_parent>

Renders the contained elements only if the current contextual page has no parent, i.e.
is the root page.

Usage

<r:unless_parent>...</r:unless_parent>

<r:if_children>

Renders the contained elements only if the current contextual page has one or
more child pages. The status attribute limits the status of found child pages
to the given status, the default is "published". status="all" includes all
non-virtual pages regardless of status.

Usage

<r:if_children [status="published"]>...</r:if_children>

<r:unless_children>

Renders the contained elements only if the current contextual page has no children.
The status attribute limits the status of found child pages to the given status,
the default is "published". status="all" includes all non-virtual pages
regardless of status.

Usage

<r:unless_children [status="published"]>...</r:unless_children>

<r:cycle>

Renders one of the passed values based on a global cycle counter. Use the reset
attribute to reset the cycle to the beginning. Use the name attribute to track
multiple cycles; the default is cycle.

Usage

<r:cycle values="first, second, third" [reset="true|false"] [name="cycle"]/>

<r:content>

Renders the main content of a page. Use the part attribute to select a specific
page part. By default the part attribute is set to body. Use the inherit
attribute to specify that if a page does not have a content part by that name that
the tag should render the parent’s content part. By default inherit is set to
false. Use the contextual attribute to force a part inherited from a parent
part to be evaluated in the context of the child page. By default ‘contextual’
is set to true.

Usage

<r:content/>

<r:field>

Renders the content of the field given in the name attribute.

Usage

<r:field name="Keywords" />

<r:if_content>

Renders the containing elements if all of the listed parts exist on a page.
By default the part attribute is set to body, but you may list more than one
part by separating them with a comma. Setting the optional inherit to true will
search ancestors independently for each part. By default inherit is set to false.

When listing more than one part, you may optionally set the find attribute to any
so that it will render the containing elements if any of the listed parts are found.
By default the find attribute is set to all.

Usage

<r:if_content [part="part_name"] [inherit="true|false"] [contextual="true|false"]>...</r:if_content>

<r:unless_content>

The opposite of the if_content tag. It renders the contained elements if all of the
specified parts do not exist. Setting the optional inherit to true will search
ancestors independently for each part. By default inherit is set to false.

When listing more than one part, you may optionally set the find attribute to any
so that it will not render the containing elements if any of the listed parts are found.
By default the find attribute is set to all.

Usage

<r:unless_content [part="part_name"] [inherit="true|false"] [contextual="true|false"]>...</r:unless_content>

<r:if_field>

Renders the contained elements if the field given in the name attribute exists. The tag also takes an optional equals or matches attribute; these will expand the tag if the field’s content equals or matches the given string or regex.

Usage

<r:if_field name="author" [equals|matches="John"] [ignore_case="true|false"]>...</r:if_field>

<r:unless_field>

The opposite of if_field. Renders the contained elements unless the field given in the name attribute exists. The tag also takes an optional equals or matches attribute; these will expand the tag unless the field’s content equals or matches the given string or regex.

Usage

<r:unless_field name="author" [equals|matches="John"] [ignore_case="true|false"]>...</r:unless_field>

<r:if_url>

Renders the containing elements only if the page’s url matches the regular expression
given in the matches attribute. If the ignore_case attribute is set to false, the
match is case sensitive. By default, ignore_case is set to true.

Usage

<r:if_url matches="regexp" [ignore_case="true|false"]>...</r:if_url>

<r:unless_url>

The opposite of the if_url tag.

Usage

<r:unless_url matches="regexp" [ignore_case="true|false"]>...</r:unless_url>

<r:if_ancestor_or_self>

Renders the contained elements if the current contextual page is either the actual page or one of its parents.

This is typically used inside another tag (like <r:children:each>) to add conditional mark-up if the child element is or descends from the current page.

Usage

<r:if_ancestor_or_self>...</r:if_ancestor_or_self>

<r:unless_ancestor_or_self>

Renders the contained elements unless the current contextual page is either the actual page or one of its parents.

This is typically used inside another tag (like <r:children:each>) to add conditional mark-up unless the child element is or descends from the current page.

Usage

<r:unless_ancestor_or_self>...</r:unless_ancestor_or_self>

<r:if_self>

Renders the contained elements if the current contextual page is also the actual page.

This is typically used inside another tag (like <r:children:each>) to add conditional mark-up if the child element is the current page.

Usage

<r:if_self>...</r:if_self>

<r:unless_self>

Renders the contained elements unless the current contextual page is also the actual page.

This is typically used inside another tag (like <r:children:each>) to add conditional mark-up unless the child element is the current page.

Usage

<r:unless_self>...</r:unless_self>

<r:author>

Renders the name of the author of the current page.

Usage

<r:author/>

<r:date>

Renders the date based on the current page (by default when it was published or created).
The format attribute uses the same formating codes used by the Ruby strftime function. By
default it’s set to %A, %B %d, %Y. The for attribute selects which date to render. Valid
options are published_at, created_at, updated_at, and now. now will render the
current date/time, regardless of the page.

Usage

<r:date [format="%A, %B %d, %Y"] [for="published_at"]/>

Renders a link to the page. When used as a single tag it uses the page’s title
for the link name. When used as a double tag the part in between both tags will
be used as the link text. The link tag passes all attributes over to the HTML
a tag. This is very useful for passing attributes like the class attribute
or id attribute. If the anchor attribute is passed to the tag it will
append a pound sign (#) followed by the value of the attribute to
the href attribute of the HTML a tag—effectively making an HTML anchor.

Usage

<r:link [anchor="name"] [other attributes...]/>

or

<r:link [anchor="name"] [other attributes...]>click here</r:link>

<r:breadcrumbs>

Renders a trail of breadcrumbs to the current page. The separator attribute
specifies the HTML fragment that is inserted between each of the breadcrumbs. By
default it is set to >. The boolean nolinks attribute can be specified to render
breadcrumbs in plain text, without any links (useful when generating title tag).

Usage

<r:breadcrumbs [separator="separator_string"] [nolinks="true"]/>

<r:snippet>

Renders the snippet specified in the name attribute within the context of a page.

Usage

<r:snippet name="snippet_name"/>

When used as a double tag, the part in between both tags may be used within the
snippet itself, being substituted in place of <r:yield/>.

Usage

<r:snippet name="snippet_name">Lorem ipsum dolor...</r:snippet>

<r:yield>

Used within a snippet as a placeholder for substitution of child content, when
the snippet is called as a double tag.

Usage (within a snippet):

<div id="outer">
  <p>before</p>
  <r:yield/>
  <p>after</p>
</div>

If the above snippet was named “yielding”, you could call it from any Page,
Layout or Snippet as follows:

<r:snippet name="yielding">Content within</r:snippet>

Which would output the following:

<div id="outer">
  <p>before</p>
  Content within
  <p>after</p>
</div>

When called in the context of a Page or a Layout, <r:yield/> outputs nothing.

<r:find>

Inside this tag all page related tags refer to the page found at the url attribute.
@url@s may be relative or absolute paths.

Usage

<r:find url="value_to_find">...</r:find>

<r:random>

Randomly renders one of the options specified by the option tags.

Usage

<r:random>
  <r:option>...</r:option>
  <r:option>...</r:option>
  ...
</r:random>

<r:option>

see <r:random>

<r:comment>

Nothing inside a set of comment tags is rendered.

Usage

<r:comment>...</r:comment>

<r:escape_html>

Escapes angle brackets, etc. for rendering in an HTML document.

Usage

<r:escape_html>...</r:escape_html>

<r:rfc1123_date>

Outputs the published date using the format mandated by RFC 1123. (Ideal for RSS feeds.)

Usage

<r:rfc1123_date/>

<r:navigation>

Renders a list of links specified in the urls attribute according to three
states:

  • normal specifies the normal state for the link
  • here specifies the state of the link when the url matches the current
    page’s URL
  • selected specifies the state of the link when the current page matches
    is a child of the specified url

The between tag specifies what should be inserted in between each of the links.

Usage

<r:navigation urls="[Title: url | Title: url | ...]">
  <r:normal><a href="<r:url />"><r:title /></a></r:normal>
  <r:here><strong><r:title /></strong></r:here>
  <r:selected><strong><a href="<r:url />"><r:title /></a></strong></r:selected>
  <r:between> | </r:between>
</r:navigation>

<r:if_dev>

Renders the containing elements only if Radiant in is development mode.

Usage

<r:if_dev>...</r:if_dev>

<r:unless_dev>

The opposite of the if_dev tag.

Usage

<r:unless_dev>...</r:unless_dev>

<r:status>

Prints the page’s status as a string. Optional attribute ‘downcase’
will cause the status to be all lowercase.

Usage

<r:status [downcase='true']/>

<r:meta>

The namespace for ‘meta’ attributes. If used as a singleton tag, both the description
and keywords fields will be output as <meta /> tags unless the attribute ‘tag’ is set to ‘false’.

Usage:

<r:meta [tag="false"]/>

or

<r:meta>
  <r:description [tag="false"]/>
  <r:keywords [tag="false"]/>
</r:meta>

<r:meta:description>

Emits the page description field in a meta tag, unless attribute
‘tag’ is set to ‘false’.

Usage:

<r:meta:description [tag="false"]/>

<r:meta:keywords>

Emits the page keywords field in a meta tag, unless attribute
‘tag’ is set to ‘false’.

Usage:

<r:meta:keywords [tag="false"]/>
Clone this wiki locally