Filters

The filters collection is a unique and alphabetically sorted list of all tags that are assigned to the pages in the current pagelist. While iterating the filters using a foreach loop, the current tag can be accessed using the :filter variable. The filters collection is typically used to build a filter menu for a pagelist.

<@ foreach in filters @>
  <span>@{ :filter }</span>
<@ end @>

Example

The following example creates a filter menu for the children of the current page. The selected tag is passed as a query string parameter. The queryStringMerge function makes sure that other existing parameters, like a sort order or a search, are kept.

<@ newPagelist {
  type: 'children',
  filter: @{ ?filter }
} @>
<nav>
  <a href="?<@ queryStringMerge { filter: '' } @>">All</a>
  <@ foreach in filters @>
    <a
      href="?<@ queryStringMerge { filter: @{ :filter } } @>"
      <@ if @{ :filter } = @{ ?filter } @>class="active"<@ end @>
    >
      @{ :filter }
    </a>
  <@ end @>
</nav>
<@ foreach in pagelist @>
  <a href="@{ url }">@{ title }</a>
<@ end @>
Tags Control Structures