Pages Plugin
The pages plugin displays data about pages in the page tree. If you want information about the current page, you can use the current page plugin.
pages:url
{{ pages:url }}
Gets a page's URL based on its ID.
Attributes
Name | Default | Required | Description |
---|---|---|---|
id | None | Yes | The page id of the page you want the URL for. |
Example
{{ pages:url id="4" }}
Returns:
'http://www.example.com/about'
pages:children
{{ pages:children }}
Tag pair that loops through the children of a parent page.
Attributes
Name | Default | Required | Description |
---|---|---|---|
id | None | Yes | Page ID of parent page whose children you want. |
limit | 10 | No | Number of pages to return. |
order-by | order | No | Order by column name |
order-dir | ASC | No | Order direction. Ex: ASC or DESC |
include-types | None | No | Allows you to return only specific Page Types. Pass Page Type ID in a pipe-separated list: Ex. 4|6|7 |
Example
{{ pages:children id="1" limit="2" }}
<h2>{{ title }}</h2>
{{ /pages:children }}
Returns:
<h2>Child One</h2>
<h2>Child Two</h2>
You can also return any custom content variables by using the array.
{{ pages:children id="1" }}
<h2>{{ title }}</h2>
{{ custom_fields }}
<p>{{ introduction }}</p>
{{ body }}
{{ /custom_fields }}
{{ /pages:children }}
pages:display
{{ pages:display }}
Display a page inside other content.
Attributes
Name | Default | Required | Description |
---|---|---|---|
id | None | No | ID of the page you want to display. |
slug | None | No | Slug of the page you want to display. |
Examples
{{ pages:display slug="home" }}
<h2>{{ title }}</h2>
{{ /pages:display }}
Returns:
<h2>Page Title</h2>
You can also return any custom field variables by using the array.
{{ pages:display slug="home" }}
<h2>{{ title }}</h2>
{{ custom_fields }}
{{ body }}
<p>{{ introduction }}</p>
{{ /custom_fields }}
{{ /pages:display }}
pages:chunk
{{ pages:chunk }}
A tag that allows any one page chunk to be displayed anywhere on the site, even inside another page's content.
Page chunks were discontinued in PyroCMS 2.2, but are still present in installations upgraded from 2.1.x to 2.2.
Attributes
Name | Default | Required | Description |
---|---|---|---|
id | None | Yes | ID of the page that the chunk belongs to. |
name | None | Yes | The name of the page chunk that you want to display. |
Example
{{ pages:chunk id="1" name="default" }}
Returns:
<p>Welcome to our homepage. We have not quite finished setting up our website yet, but please add us to your bookmarks and come back soon.</p>
pages:is
{{ pages:is }}
A tag that confirms if a page is a direct child of another page, or is a descendent of another page.
Attributes
Name | Default | Required | Description |
---|---|---|---|
child | None | No | ID or Slug of the page whose relation you want to check. |
children | None | No | Children separated by a comma. |
parent | None | No | ID or Slug of the page to check if it is a parent of child. |
descendent | None | No | ID or Slug of the page to check if it is a descendent of child. |
Example A
{{ if {pages:is child="ingredients" parent="cookbook"} == true }}
<p>Click here to see table of contents cookbook</p>
{{ endif }}
Returns:
<p>Click here to see table of contents cookbook</p>
Example B
{{ if {pages:is child="terms-and-conditions" parent="information"} == true }}
<body class="terms information">
{{ else }}
<body class="">
{{ endif }}
Returns:
<body class="terms information">
pages:page_tree
{{ pages:page_tree }}
A tag that displays a tree of pages starting from the id specified.
Attributes
Name | Default | Required | Description |
---|---|---|---|
start-id | None | Yes | ID of the page you want to display children for. |
disable-levels | None | No | A list of page slugs to skip separated by the pipe character. Example: secret|super-secret|nuclear-codes |
order-by | title | No | Database column to order pages by. |
order-dir | asc | No | Direction to sort the pages. |
Examples
{{ pages:page_tree start-id="20" }}
Returns:
<ul>
<li><a href="http://example.com/page">Page Name</a>
<ul>
<li><a href="http://example.com/page/child">Child Name</a></li>
</ul>
</li>
</ul>