Changing The Default Post Display
Customize how posts display on your Oncord powered website
The <data:repeater> tag is used to display posts throughout Oncord powered websites. This tag loops through a nominated data source and renders the content between the opening and closing tags for each returned element.
A Simple Example
See the below example of an <data:repeater> tag. The below code will produce a list <ul> of all posts of a certain post category.
You can display any post field using the above method, for a complete list of default post fields see the API reference here (scroll to the bottom of the page to see fields).
Generated Post Category Pages
When an admin user creates a new post category, a page is automatically generated which contains an <data:repeater> tag. On the generated pages the "datasource" attribute of the data repeater is automatically set to retrieve data from the newly created post category.
Before altering the default post display configuration, it's worth further examining the page which is generated when an admin user creates a new post category (eg. news). The following code is automatically added to a post category page upon creation:
Explaining The Above Code
Line 1: This heading is automatically set to the post category title when the post category is created.
Line 2: An opening <data:repeater> tag. This tag acts similar to a for loop, retrieving everything from a nominated data source and displaying the code between the opening and closing tags (line 3) for each returned element. In the above case the data source will retrieve all posts that have a category id of "3". Each post category is assigned a unique id. Select a post category through the admin panel to determine its id.
Line 3: The code on this line will render the post list display, which is accessible on the post configuration admin panel page (explained below).
Altering The Post Display Configuration
- Navigate to Dashboard > Website > Designs.
- Below the relevant website design, select the "Posts List Display" option.
- You can choose from a selection of prebuilt post displays, or customise source
The following code is used by default for the post list display configuration:
Each post is referenced by the variable $post. PHP can be used to display various fields associated with the post. For a full list of post fields see the API reference here (scroll to the bottom of the page).