Description of GUITopic
Up to Plone Development FAQGUITopic
This product introduces a new content type, "GUITopic", which extends Topic (Smart Folder). It allows the content contributor to define a smart folder, just as they can with the Smart Folder type. Additionally, it presents two HTML editors ("Body" and "Item") for defining how the view of the smart folder output will look.
The "Body" editor is used to define the HTML which surrounds the list of search results. The "Item" editor is used to define the HTML for a single list item. Special tags are used to insert dynamic content into the HTML. By using these tags, we don't go so far as to allow a content contributor to write ZPT code (this is not a good idea, see http://plone.org/documentation/faq/dynamic-content), but we do allow the contributor to add dynamic content inside static HTML, which is something that isn't possible out of the box in Plone.
Within the "Body" HTML, a single tag is available, "${items}". Wherever this tag is inserted will be where the list of items will be injected when the page is rendered. If the tag is omitted, the items will be injected at the end of the Body, effectively making it a header. If it appears more than once, only the first instance will be used.
Within the "Item" HTML, tags are of the format "${fieldName}", where fieldName is a name of a field or method on the content item. So for instance, the title of the item would be ${Title}, and the description would be ${Description}.
For programming-like tasks (for instance, we want to customize a date format), just add a method to the content type that does what you need. There is one programming-like construct, the "if defined" construct, available as a tag in the "Item" HTML, simply because it is a commonly found need and is a great help to not have to implement in the content type every time it is needed. It is used as follows:
[[if ${address2}]]${address2}
[[endif]]
It can also be used with multiple fields, effectively "OR"ing them together:
[[if ${firstName} ${lastName}]]Name: ${firstName} ${lastName}[[endif]]
The current implementation doesn't allow nesting of the "if defined", but that would be a nice enhancement if somebody wants to do it.
I don't expect to see a lot of other programming constructs developed for this product. The idea is that this product is meant for end users, not developers. We already have a programming language for developers, called ZPT, and there shouldn't be any reason to invent another language on top of it. On the other hand, we shouldn't have to use a ZPT developer every time we want to change HTML, like changing bullets to numbered items, and that's what this product helps us avoid.
Examples:
A simple bulleted list of titles and descriptions: Body:
- ${items}
Two columns of data, using CSS: Body:
${Description}
A table of titles and descriptions Body:
${items}| Title | Description |
|---|
| ${Title} | ${Description} |
Note, for tables, the Item HTML may also include a (redundant) TABLE tag. This is for two reasons: 1. Many WYSIWYG editors won't allow you to define HTML that has a TR with no enclosing TABLE tag. 2. By putting it in a table, you can actually see your row as it would look, within the WYSIWYG view. When rendering this example, the
and