Sub Pages API
The Sub Pages API lets you get a list of subpages for a single page.
You can get the API tag with the page UUID under the "Page API" tab when editing a page.
Usage
The API will only return an array of pages. It's not intended to be used with the template() parameter. You will assign the data returned from the API to a variable.
{% set pages = _api.page.subPages.pageId('892abfde-c777-48a6-9db1-d5067de6f69c') %}
By default, pages are ordered by their Display Name. You can order them by the SEO title if you want.
Order by the page title:
{% set pages = _api.page.subPages.pageId('23-186133-805867-470935-937075').orderBy('title') %}
Order by the descriptive name:
{% set pages = _api.page.subPages.pageId('23-186133-805867-470935-937075').orderBy('name') %}
{# Since ordering by the name is the default, you can leave the orderBy() parameter off. #}
{% set pages = _api.page.subPages.pageId('23-186133-805867-470935-937075') %}
API Parameters
Parameter | Description |
---|---|
pageId | Sets the UUID of the page to get subpages for. Get this from the "Page API" tab when editing a page. |
orderBy | Sets the value to order by. Allowed values are:
|
Data returned from the API
The API returns an array of pages. For each page the following information is provided.
- name: The page name. This comes from the "Page name" field when editing a page.
- slug: The URL slug for the page.
- seoTitle: The SEO page title for the page.
- url: The full URL for the page (not including the domain name).
Example
Below is some example code that gets the subpages and outputs them as a list of links.
{% set pages = _api.page.subPages.pageId('23-186133-805867-470935-937075') %}
{% if pages %}
<ul>
{% for page in pages %}
<li><a href="{{ page.url }}">{{ page.name }}</a></li>
{% endfor %}
</ul>
{% endif %}