Content - List templates

List configuration

Once you’ve properly set up your page types you have the option to create a list page for each type. List pages are a way to provide visitors with an overview page that contains a specific type of content – some examples are a list of news articles or blog entries.

List configurations can be set in the admin panel and not in configuration files:
2016-08-15 at 01.36

Once you’ve set up a list url, users will be able to access the default list page.

List public template

All page types that have a list url set up will require a public list template. A page template will define the design and display of the list of ContentPage objects on this page. Usually this is a list of links to the ContentPage subpages. As usual, the naming is important here – you need to add it to /app/view/contentpage/*_list.html so in the case of our article type example the file would go in /app/view/contentpage/article_list.html.

You will have access to the variables {{content.contentpages}} (which is a zajFetcher object list of all the ContentPage objects that are of this type) and the {{content.contentpagetypesetting}} (a ContentPageTypeSetting object that defines the current type’s settings).

By default the list is paginated to {{#contentpage_list_pagination#}} (set in content.conf.ini), but you can override this in the list controller or in the config file.

List controller

You may want to preprocess the list before you display it – for example if there are any custom filtering or search options on your site. As with contentpages and contentpagesections, a special magic method is called before the list template is displayed.

Again, the naming is important here – you need to add it to /app/controller/contentpage/*.ctl.php so in the case of our article example the file would go in /app/controller/contentpage/article.ctl.php. Then you can create a __list() method which takes a single $contentpages parameter. Here is a working example:

Outlast Web & Mobile Development (c) 2019 | Privacy Policy |