Post Article Navigation
Dynamic navigation which is populated with post articles.
This article explains how to create dynamic navigation which is automatically populated by post articles. This can be useful for creating small sidebar menus of recent posts, or footer navigation which lists post article titles.
How it Works
The navigation will be populated with the titles of all post articles of a certain post category. The <ss:data:repeater> will be used
to retrieve the post articles, with the data source being set to a call to the Oncord API.
The <ss:data:repeater> is similar to a for loop which will repeat everything inside the tag until there are no more items left to
return from a data source.
- Navigation code
- CSS styling
The Data Repeater
The data repeater specified above uses the following attributes, for a list of all attributes please see the API here.
as="post" - This attribute determines the name of the variable to be registered for the repeating element. In this case the variable has been given the name "post" and is therefore referenced as $post.
datalimit="4" - This attribute defines the maximum number of rows the data repeater will return. In this case it was decided that there needed to be a maximum of four articles displayed.
datasource="\Components\Website\Posts::getAllForCategory(1)" - This attribute defines the data source of the repeater. In this example all articles where the category id=1 will be returned. To find a post category id navigate to the post categories page of the dashboard, then click a category to open the category edit page. On this page there is a tab labelled "Developer Info", which lists the post category ID.