Building Custom Index Pages
Date: 07-05-2007 14:32 Views: 9177
MonkeyCMS has a powerful modular templating system and each page is made of reusable building blocks. There are two kinds of pages - Content Pages and Index Pages. Content Pages are defined by Content Templates while Index Pages are built entirely from Fixed Templates. Any Fixed Template can be considered a page, although it is recommended that you set the type of any Fixed Template you want to use as an Index Page to 'Page Template'.
Index Pages are accessed using the index.php script with the page query string parameter as follows:
The index.php script displays the following templates:
By default, if no page parameter is passed, the Default Fixed Template is displayed - this would usually be the front page of your site. You can override this default in your Site Settings.
An Example Page
Below we will create a new page to display a list of Book Reviews. To start with ensure you have created a definition named Book Reviews.
There are a number of steps to carry out to create the Book Reviews index:
- Create an Index template for each Book Review
- Create an Advanced Index of Book Reviews
- Create the BookReviews Index Page
1. Create an Index template for each Book Review
Advanced Indexes allow you to specify a template to display each piece of content. This should be created before you define the advanced index, but it is possible to assign this template later if neccessary. We'll create a basic Index template called Index:BookReview as follows.
- Browse to Layout > Skin Manager and select the skin you would like to work with.
- Click Add Template at the top of the Fixed Templates box
- In the Editor window enter the Template Name: Index:BookReview and the Template Type: Index
- In the template text box enter the following template:
- Click Save Template
2. Create an Advanced Index of Book Reviews
To create the Advanced Index, carry out the following steps:
- From the Skin Manager click Add Index at the top of the Advanced Indexes box
- Enter the title 'BookReviews'
- Check the 'Book Reviews' check box in the definition list
- Select the Index:BookReviews template created above from the drop down list of templates
- Leave the ordering as title and ascending as an alphabetically ordered index would be most appropriate
- Click 'Save'
3. Create the BookReviews Index Page
The final step is to create the main template for the page. We'll base it on the Default page, but this isn't necessary and you could create a page from scratch. For consistency and ease this is the most appropriate thing to do for this tutorial.
In the Skin Mananger, expand the Page Templates list in the Fixed Templates box and click to modify the Default template. Copy the template text in the editor and then follow the instructions below:
- Click Add Template at the top of the Fixed Templates box.
- Enter the title 'Book Reviews'
- In the Template Type drop down select the 'Page Template' option
- Paste the Default template you copied into the template text box and modify to replace the 'Latest Updates' title with 'Book Reviews', remove the Announcements display line and remove the 'More' link text so the template looks like this:
- Click Save Template
Viewing the Book Reviews index
Ensure that the correct skin is in use, either by selecting it in your site user settings or by setting the default site template in the Site Settings, and browse to:
If you have any book reviews uploaded to your site they'll appear within the Book Reviews index. If not you'll see the title and not a lot else!