Templating

Here is some useful information to help you with creating templates for the Page Picker+ block.

Code hinting

All templates use the PHP doc notation to trigger code hinting in any IDE that supports it. This makes developing templates a lot easier.

Compatibility with the Autonav and Pagelist blocks

The Page Picker+ ships with a number of templates. In addition to some custom templates it also includes the templates from Concrete's Autonav and Pagelist block. The templates of these blocks are compatible with the Page Picker+. This means you can use this block to create the same, identical content as you can with the Autonav and Pagelist block. Of course, the Page Picker+ does not have all the options the Autonav and Pagelist block because it's a different kind of block and some options wouldn't make sense. The Pagelist block for example, offers you the option to provide a text when there aren't any pages to show to the user. The Page Picker+ block doesn't have this option but does set the variable ($noResultsMessage) by default in order to make the templates compatible.

Nested and flat arrays of pages

The power of the Page Picker+ is the possibility to create nested lists; add one or more pages beneath another page. This is great for creating nested navigation. Some templates do not use nesting, like the thumbnail grid for example. Others, like the Autonav template and the Nested Navigation List template do. Depending on the type of template you are trying to create you will need either an array of nested pages or a flat array of pages. Both are available in the templates:

$pages is a flat array of pages; there's no composition here. Use this array to create templates where you don't want nesting.

$pagePickerPages is an array of Page Picker+ Pages; each of these pages can have an array of child pages which on their turn can have an array of child pages. So if you pick 10 pages of which 8 of these pages are nested under two of the ten pages, then the pagePickerPages array will only contain 2 pages (while $pages will be an array of 10 pages); the other 8 are descendants of these two pages. A Page Picker+ Page has various methods to expose those descendants, like these methods:

  • getChildren
  • getDescendants
  • flatten

A Page Picker+ Page is a wrapper around the original Concrete page wich you selected. You can retrieve the original Concrete page by calling the method getPage on it, or by just evoking the calls on the object directly: a Page Picker+ Page proxies all calls to undefined methods and properties on to the Concrete Page, so you can do $pagePickerPage->getCollectionID() directly instead of : $pagePickerPage->getPage()->getCollectionID().

There is also the option to request an array of Autonav objects from the controller, such as is done in the templates of the Autonav block. This is useful for creating nested lists (See : the autonav_default template). The objects returned are of the stdClass type and are the same as the ones used in the Autonav block.

Something to keep in mind when using or creating navigation templates

The html generated by the Autonav and Pagelist templates always resembles the original structure of the pages in your dashboard's sitemap. Because the Page Picker+ lets you create your own order, the output will follow that exact order. You could put the homepage under 'About > Contact' for example, like this : 'About > Contact > Home'. While this particular example doesn't make a lot of sense, their are a lot of scenario's where you could want to create a navigation structure that differs from your sitemap's structure.