Using custom templates as front page
This how-to shows you a couple of ways in which you can put a news listing on the front page of your portal. The technique can also be used for any other type of template, and any folder other than the portal root.
The portal root is a folderish object, like a regular 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_htmlis found, this is displayed instead. The "Welcome to Plone" page you see in a fresh Plone installation is a Document with the nameindex_html. - If a property called
default_pageexists 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
/manageto the end of the URL to your portal root, e.g.http://localhost:8080/plone-instance/manage - In the portal root, click the
Propertiestab - Add a new property of type
lineswith the namedefault_page - In this, put
newsand 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 and available on the plone.org products area. It requires 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 productsin the Plone Control Panel, or viaportal_quickinstallerin 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 listNews Items, sorted byDatein reverse order, showing only items in thepublishedstate, 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 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.