User Tools

Site Tools


mpiwgmanager

Table of Contents

MPIWG Manager

A Zope product by Christopher Mielack, 2009/2010

Code

Info

This product was designed to be a versatile container-item-combination that allows items to easily be displayed in Zope Page Templates, represent virtually anything and support bilingual (english/german) content input, which makes it easy to maintain items across the different (english/german) versions of webpages, resulting in less consistency issues.

Objects:

  • MPIWG Manager - Container class. Works like a folder and provides functionalities such as returning the MPIWG Items in a list, sorted by date.

For every instance of the MPIWG Manager a blueprint for newly created items can be defined in the tab “Edit Defaults”.

  • MPIWG Item - Item class. Every item is located in its MPIWG Manager and can contain a set of properties with german/english label and german/english content. Also, the properties can be ordered using a weight number.

Tutorial

If for example you want to use the product to post news on a website in zope, you would go about it as follows:

  1. Create an MPIWGManager object, e.g. called “news”
  2. Then, in the “news” object, using the tab “Edit Defaults”, you can preset some datafields that items created in this MPIWGManager will contain by default. Note that these preset fields can also manually be deleted in the item objects if necessary. Go ahead and add 2 new fields by entering “2” in the textbox and clicking “Update”.
  3. The two new properties now should get unique ids, in this case for example “summary” and “story”. Also, the field label (“Feldname”) should be set in both german and english.
  4. After clicking “Update” again, we can go back to the Zope Management Interface and create some Items inside the MPIWG Manager. Go ahead and create one. Immediately, you will see a form, similarly to the defaults manage, that lets you input all the info in both english and german. You could also change the date if you wanted.
  5. Enter some text into the fields, click update, go back to the ZMI, and, if you want, create some more Items.
  6. When you are done creating Items, you can now create a Page Template that displays the news. Create a new Template with the usual HTML structure and a place where you want the news to appear.
  7. Assuming that the template is placed in the same folder as the MPIWG Manager or inside of it, the following code will loop all of your news item and display them as html:
      <tal:block tal:repeat="entry python: here.news.getSortedByDate()">
       <h3 tal:content="python: entry.getDate()"/>
       <h1 tal:content="python: entry.getInfo('title','EN')"/>
       <p tal:content="python: entry.getInfo('summary','EN')"/>
      </tal:block>
  1. The method getSortedByDate() returns all the items in the manager as a list sorted by date (ascending). The different properties of the Item can then be accessed by using the MPIWGItem.getInfo(…) method. The first parameter is the id of the property, the second one defines the language used (either 'EN' or 'DE'; defaults to 'EN' if left out).

I hope that helps.

mpiwgmanager.txt · Last modified: 2010/01/29 17:00 (external edit)