Docs: Other pages and menus
Other pages and menus
Reaching beyond the current page: page, children, siblings, pages, breadcrumbs and menu.
page($ref = 'self') #
One page as a pages() item (E), or null. $ref is 'self', an id or a path such as docs/install. A draft is null, by id and by path alike.
<?php $parent = $this->page($this->page()['parent_id']); ?>
<?php if ($parent): ?><a href="<?= $parent['url'] ?>"><?= $parent['title'] ?></a><?php endif; ?>
children($ref = 'self', $query = []) #
The pages under $ref, in the pages() envelope. A parent the visitor may not see lists nothing, with error: 'parent'.
<?php foreach ($this->children('self', ['sort' => 'title'])['items'] as $c): ?><a href="<?= $c['url'] ?>"><?= $c['title'] ?></a><?php endforeach; ?>
siblings($ref = 'self', $query = []) #
The pages beside $ref under the same parent, $ref included. current marks the page being shown, so the item after it is the next link.
<?php $list = $this->siblings()['items']; $at = array_search(true, array_column($list, 'current'), true); ?>
<?php if ($at !== false && isset($list[$at + 1])): ?><a href="<?= $list[$at + 1]['url'] ?>">Next</a><?php endif; ?>
pages($query = []) #
Lists pages by Layout, parent, what links to a page, or a field's value, sorted and paged. Returns {items, total, page, pages, limit, error} (E).
<?php foreach ($this->pages(['template' => 'post', 'limit' => 5, 'exclude' => 'self'])['items'] as $p): ?>
<a href="<?= $p['url'] ?>"><?= $p['title'] ?></a>
<?php endforeach; ?>
breadcrumbs() #
The trail to this page as {title, url, current} (P).
<?php foreach ($this->breadcrumbs() as $c): ?><a href="<?= htmlspecialchars($c['url'], ENT_QUOTES, 'UTF-8') ?>"><?= htmlspecialchars($c['title'], ENT_QUOTES, 'UTF-8') ?></a><?php endforeach; ?>
menu($identifier) #
A menu as a tree of {title, url, target, active, heading, change, children} (P). An unsafe URL scheme is already #.
<?php foreach ($this->menu('main') as $item): ?>
<a href="<?= htmlspecialchars($item['url'], ENT_QUOTES, 'UTF-8') ?>"><?= htmlspecialchars($item['title'], ENT_QUOTES, 'UTF-8') ?></a>
<?php endforeach; ?>