You are not logged in Log in Join
You are here: Home » Download Zope Products » Content Management Framework » CMF Documentation » Developing for CMF » Building a FAQ Content Type with ZClasses

Log in
Name

Password

 

Building a FAQ Content Type with ZClasses

How the 'FAQ' type on the dogbowl was built.

Overview

The zope-cmf mailing list had begun to compile a list of FAQs; I wanted to capture them on the dogbowl as content, and decided to make a simple ZClass to represent them.

Recipe

  1. In the Control_Panel/Products directory, add a product, CMF_FAQ.
  2. In the new product, add a ZClass, FAQ, with CMFCore.PortalContent and CMFDefault.DefaultDublinCoreImpl as bases.
  3. Delete the permission, FAQ_permission.
  4. Edit the factory, FAQ_factory, setting the permission to "Add portal content".
  5. In the ZClass, FAQ, add a propertysheet, FAQ_properties. Add the following properties to it:
    faq_sections
    a tokens property; give it a default value of 1 1. Making the section a tuple of seciton IDs makes sorting by section work well.
    faq_question
    a text property.
    faq_reply
    a text property.
    faq_urls
    a lines property. Each line will represent the URL of a resource (list posting, dogbowl document, etc.) related to the question.
  6. In the "Methods" tab of the ZClass, add a PythonScript, Title. Its body should be:
            import string
            section = string.join( context.faq_sections, '.' )
            return '%s %s' % ( section, context.faq_question )
    
  7. In your CMFSite's portal_skins, add a new folder, faq_skins. To it, add the following methods:
    faq_view
    (DTML Method or Page Template); a straightforward presentation of the FAQ's properties.
    faq_edit_form
    (DTML Method or Page Template); a straigtforward interface for editing the FAQ's properties; posts to faq_edit.
    faq_edit
    (PythonScript); calls manage_changeProperties on the FAQ_properties propertysheet of the FAQ, and redirects to the faq_edit view.

    Add this folder to the skin search path of the Basic skin (and/or others germane to your site).

  8. In your CMFSite's portal_types tool, add a new FactoryTypeInformation object, FAQ. Its product property should be set to "CMF_FAQ", and its factory property to "FAQ_add". On its "Actions" tab, add the following actions:
    view
    mapped to faq_view.
    edit
    mapped to faq_edit_form.
    metadata
    mapped to metadata_edit_form.

You're done!

Installing the Product

Two files comprise the FAQ:

  • An export of the ZClass product. Import it into Control_Panel/Products of your Zope.
  • An export of the folder containing the skins methods. Import it into the portal_skins of your CMFSite, and add it to the search paths of the Basic (or other) skin.