Using Custom Templates as Front Page
The portal root is a folderish object, like a regular Folder.
Plone 4
Most of the Plone 2.0 and 2.1 default page techniques still work in Plone 4. If you want to have your own page templates or browser views as the front page type, there are a couple of ways to approach the problem. To set the front page "fast and dirty":
- Go into the ZMI by appending '/manage' to the end of the URL to your portal root, e.g. 'http://localhost:8080/plone-instance/manage'
- In the portal root, click the 'Properties' tab
- Update the default_page property to be the name of the template you wish to display, minus the .pt. For example, to display the latests news set it to 'news'. Save.
- If you are registering a browser view instead a page template, add a new property of type 'string' with the name 'layout'. The value of this property will be the name of your browser view, as it was registered in configure.zcml. Save again.
If you are setting a browser view as the default page, adding the default_page property is not really necessary. However, page template lookups take precedence over browser view lookups so if your default_page is set to "front-page", the template lookup will trump the layout properties browser view lookup and your view won't be displayed. When in doubt set both the default_page and layout properties.
For a "prim and proper" solution that will satisfy more use cases (and those of greater complexity), please see http://plone.org/documentation/kb/applying-a-custom-view-to-a-specific-folder.
Plone 2.1
In Plone 2.1, this is actually quite easy. To get the "News" smart folder to be the front page, simply use the 'display' menu on the portal root, click 'Choose content item as default view...' and select the 'News' smart folder. Other documents can be selected in the same way. If you have a custom content type that is not showing up, add its type to 'portal_properties/site_properties/default_page_types' in the ZMI.
If you want to add a custom page template instead, you can add it to the list of 'view methods' that become available in the 'display' menu. This is set on a per-type basis. Go to 'portal_types/Plone Site' in the ZMI and add the id of your page template to the list of "Avaialable view methods". The same can be done for any of the stock content types (or indeed any content type which uses the new CMFDynamicViewFTI for its type information).
Plone 2.0
If you are using Plone 2.0, the following mechanisms can be used. These techniques should still work in Plone 2.1, but have been deprecated in favour of the ones described above:
By default, folderish items display a folder listing, but there are two ways you can override this:
- If an object in the folder with the id (short name) 'index_html' is found, this is displayed instead. The "Welcome to Plone" page you see in a fresh Plone installation is a Document with the name 'index_html'.
- If a property called 'default_page' exists on the folder, this will allow you to set the name of a template to use.
Setting a default_page
The 'news' tab in Plone is actually calling the template news.pt, which lives in 'portal_skins/plone_templates/news' when viewed in the ZMI. This can be called anywhere (via the magic of Zope acqusition), including, of course, in the portal root. Hence, you can use it as the 'default_page' of the portal root:
- Go into the ZMI by appending '/manage' to the end of the URL to your portal root, e.g. 'http://localhost:8080/plone-instance/manage'
- In the portal root, click the 'Properties' tab
- Add a new property of type 'lines' with the name 'default_page'
- In this, put 'news' and save the property. If you wish to display a different page template applied to this context, you can put its name here instead.
If later you wish to stop displaying a template on the front page, just delete the 'default_page' property. Similarly, if you have a folder where you'd like to display a custom template, you can apply this technique to any folder, not just the portal root.
Creating a custom listing document
The alternative solution, which will give you a little more control and allow you to specify alternative listings (e.g. of items other than news, sorted differently, or displayed differently), is to use a product such as 'ListingPages', found in the "Collective":http://sf.net/projects/collective and available "on the plone.org products area":/products/listingpages. It requires "ATReferenceBrowserWidget":/products/atreferencebrowserwidget. This essentially creates a content object in which you can set certain search criteria, and displays a list of the objects matching your criteria when you view it.
- Install ListingPages in the usual way - put it in your Products/ folder, and install it with 'Add/Remove products' in the Plone Control Panel, or via 'portal_quickinstaller' in the ZMI.
- In your portal root, delete or rename the index_html object called "Welcome to Plone" found there already.
- Add a new Simple List, and give it the short name 'index_html'. Tell it to list 'News Items', sorted by 'Date' in reverse order, showing only items in the 'published' state, and batching at 20 or items.
- Publish your list, log out, and view your front page to verify that it worked.
With ListingPages, you can create more complex lists, and even composite pages of lists and "featured items". The front page of "NanoBusiness.org":http://nanobusiness.org is managed by ListingPages, with a "Featured Item" at the top and a simple list underneath. See the README.txt in the ListingPages product for more details.
