7.12.10 Main Content Templet
The main content area where documents are displayed
Author: | Dave Kuhlman |
---|---|
Address: | dkuhlman@rexx.com http://www.rexx.com/~dkuhlman |
Revision: | 1.0a |
Date: | July 12, 2005 |
Copyright: | Copyright (c) 2005 Dave Kuhlman. All Rights Reserved. This software is subject to the provisions of the Zope Public License, Version 2.1 (ZPL): http://www.zope.org/Resources/License/ |
Abstract
This document contains notes on the process of customizing an installed CPS site. We discuss the use of CPSSkins, themes, portlets, roles, workflows, custom document types (through CPSTypeMaker and CPSSchemas), and the installation of some common products.
This document is an in-progress set of notes on how to install and customize a CPS site. My intension is to continue adding to these notes to the point where they explain something of what we need to know in order to develop Web applications on top of CPS.
This document describes work done with:
Here is what I've done:
Install Zope-2.7.5-final -- I use:
./configure --prefix=../Zope-2.7.5-home --with-python=/usr/bin/python make make install
Create a Zope instance -- In your Zope installation (Zope-2.7.5-home, in my case), run:
bin/mkzopeinstance.py
Configure your Zope instance. Do this by editing myinstance/etc/zope.conf. For example, because I often run, work with, and test several Zope instances concurrently, I usually change the port-base directive.
Test your Zope instance -- Make sure that you can connect to the ZMI (Zope management interface) of your Zope instance with your Web browser.
Download CPS-3.3.3.tar.gz. Unroll it in the Products directory of your Zope instance. You should then have things like the following:
myinstance/Products/CPSDocument/ myinstance/Products/CPSSkins/ [etc]
Restart Zope.
Create a CPS site -- In the ZMI, click on Root Folder, then add a CPSDefault Site.
Connect to your new site -- If your port is 8081 (if you set port-base to 1) and the name of your new site is mycpssite, with your Web browser, visit:
http://localhost:8081/mycpssite
CPS-3.3.3 includes several useful Products that are not automatically installed. There are several ways that you can install these Products:
The easy way -- Quick Installer:
The not-so-easy way -- a Zope External method:
In the ZMI, in the root of your CPS portal, add an External Method.
Configure the External Method as follows:
Id: some_id Title: anything or nothing Module Name: the_product.install Function Name: install
where the_product is replaced with the name of the directory under Products that contains the product you want to install.
Click on Add.
Click on your External Method, then click on the Test tab.
You can configure several features of the site by logging on as manager, then clicking on Reconfigure portal. Here are some of the features that you can configure:
CPSTypeMaker and CPSSchemas enable you to create and define custom document types. Users of your CPS site will then be able to create instances of your document type.
Use the Type Maker tool. In order to do this, you will need CPSTypeMaker and CPSSchemas. If you do not have CPSTypeMaker and CPSSchemas installed, you will need to install them. For example, you can use portal_quickinstaller in the ZMI.
When you install CPSTypeMaker, a link (Document type management, Gérer les types de documents) is added to Portal actions box of the manager's interface to the CPS portal. Clicking on this link enables the user to create and edit new document types. Editing, in this context, means adding and defining fields and widgets.
CPSTypeMaker enables you to do what you would have
TypeMakerTool is included in the CPS distribution.
To install TypeMakerTool in your portal, do the following: Within in the ZMI, click on portal_quickinstaller. Select CPSSchemas and CPSTypeMaker under installable products, then click on Install.
Or, create an ExternalMethod in your portal which points to CPSTypeMaker.install, function install. Then click on the Test tab in that ExternalMethod.
In order to use CPSTypeMaker, you must be logged on as the manager of your portal.
To create a new document type, do the following:
Questions:
Click on Type Maker General configuration in Object actions or Configuration générale de Type Maker in Actions de l'objet.
Here are a few notes on configuration items:
CPSTypeMaker is basically a GUI withing a CPS portal that enables the user to define a document type built on CPSSchemas. In other words, CPSTypeMaker enables you to do through your CPS portal GUI what you could do within the ZMI using tools such as portal_types, portal_layouts, etc.
CPSTypeMaker enables you to define a document type by adding widgets of different types to your document type definition.
The remainder of this section describes some of the field/widget types that can be added to a document defined through CPSTypeMaker. These field/widget types are the same ones supported by CPSSchemas.
To configure any of the fields you have created, click on the tool symbol (it looks like a wrench, to me) next to the field.
The following properties are common to all widget types. They are inherited from class CPSWidget in CPSSchemas.Widget.py.
Properties:
Defined by class CPSAttachedFileWidget in module CPSSchemas/ExtendedWidgets.py which subclasses CPSFileWidget in module CPSSchemas/BasicWidgets.py.
Properties:
Deletable -- Specify yes if you want the user to be able to specify that no file is to be uploaded.
Maximum file size -- The maximum allowed size for uploaded files.
Allowed file suffixes -- If you want to restrict uploaded files to a set of file suffixes. Enter them one per line and include the period if approprite, for example:
.zip .bz2 .gz
Defined by class CPSBooleanWidget in module CPSSchemas/BasicWidgets.py.
Properties:
Defined by class CPSDateWidget in module CPSSchemas/BasicWidgets.py.
Properties:
Defined by class CPSDateTimeWidget in module CPSSchemas/ExtendedWidgets.py.
Properties:
Defined by class CPSFloatWidget in module CPSSchemas/BasicWidgets.py.
Properties:
Defined by class CPSFloatWidget in module CPSSchemas/BasicWidgets.py.
Properties:
Defined by class CPSIntWidget in module CPSSchemas/BasicWidgets.py.
Properties:
A password field. Provides some error checking on passwords, as well as hiding typed entries.
Defined by class CPSPasswordWidget in module CPSSchemas/BasicWidgets.py which subclasses CPSStringWidget in module CPSSchemas/BasicWidgets.py.
A RichTextEditor is like TextArea, but uses the RichText widget to edit text in Edit mode.
Defined by class CPSRichTextEditorWidget in module CPSSchemas/ExtendedWidgets.py.
Properties:
Defined by class CPSSelectWidget in module CPSSchemas/BasicWidgets.py.
Defined by class CPSStringWidget in module CPSSchemas/BasicWidgets.py.
Properties:
Defined by class CPSStringWidget in module CPSSchemas/BasicWidgets.py.
Properties:
An OrderedList is like an UnorderedList, except that each item is prepended by a item number. It is rendered as an HTML <ol> element.
Defined by class CPSOrderedListWidget in module CPSSchemas/BasicWidgets.py.
A list of items (strings) to be displayed. It is rendered as an HTML <ul> element.
Defined by class CPSUnorderedListWidget in module CPSSchemas/BasicWidgets.py.
You can customize existing CPS document types, in those that are implemented with and based on CPSSchemas. There are two very different ways to do this. The choice between these two methods depends on your needs:
Existing document types are represented in your site which you can view in the ZMI. Here are some places that you can look.
Mostly, this tool defines the appearance of each document type when it is edited or viewed (rendered).
After you click on portal_layouts, select a document type, then under the Widgets tab, click on the field to be customized. Here are some of the things you can customize:
CPSSkins enables you to customize the look of your CPS site. Through it you can customize the color and styles of objects on your page. You can also change the arrangement and location of objects on the page.
CPSSkins effectively separates (changes to) appearance from behaviour of your site.
You can find more documentation on CPSSkins at: http://www.medic.chalmers.se/~jmo/CPS/.
Layouts portlets, boxes, slots, styles, and themes -- What are they?
CPSSkins separates two distinct roles:
And because of these two roles, there are two separate editors:
And, to understand this, it is necessary to learn and distinguish the following concepts in the context of CPS3:
CPSSkins is included in the distribution of recent versions of CPS.
You may need to use portal_quickinstaller in the ZMI to install it in your portal.
To enter CPSSkins, click on Portal Themes under Portal actions.
You can also access the portlet and themes editors through the keyboard:
One of the existing skins may be just right for you or may be closer to what you want. In order to set a theme as the default, do either of the following:
Then click on Exit to return to your portal and view the selected theme.
You can do this repeatedly to try out different themes.
If you are going to customize an existing theme, you are likely to want make a copy of that theme first. To do so, enter the Skins/Themes editor, then click on the pencil icon next to the name of the theme you want to copy in the tabs across the top of the page. Now, select Duplicate from the drop-down menu.
Perhaps, you want to rename your new theme. To do so, click on the pencil icon in the tab for your theme near the top of the page. (It is likely to have been added as a new tab at the left.) Select Edit from the drop-down menu. Now, in the pop-up editor window, change the name and click on Modify.
Next, you will want to set this as the theme to be used by your site, so click on the radio button under Default theme corresponding to your new site, then click on Modify.
Now that you have created a new theme with your name on it, you can make your changes to this copy, rather than to the original theme.
You can change the look of each of the boxes in your theme. Here is how.
Enter the theme editor, then click on one of the boxes in your them. Now you can either click on Set styles or you can click on Edit and then click on the styles tab.
Next notice the various types of styles of the box that you can customize. These style types are:
For each of these style types, you have two alternatives:
After clicking on the Style tab in the edit window for the box you wish to modify, click on the icon next to the style type that you want to change. You can now modify that existing style. But, notice that this style may be in use by other portal boxes as well. So, in a box at the top of the style edit window, you will be warned about this multiple use and there is a button/link that will enable you to create a copy of the style if you wish.
We've already you are able to create a new style by copying an existing one when you attempt to edit the existing style. Now we'll create a new style from scratch.
To do so, click on the Styles button at the very top of the page. Now click on the style type for which you want to create a new style, for example Area shape or Area color. You will then see one of more existing styles of this type. Click on the create (plus) button to create and edit a new one. Or you can copy and paste (and rename, if you like) an existing style of this type.
Next, edit the style to get the appearance you want.
And, finally, return to WYSIWYG mode, click on the box you want to customize, select Set styles, and assign your new style to the box.
For details about customizing styles, see the CPSSkins book: CPSSkins a WYSIWYG Theme editor for CMF, CPS and Plone, which you can find here: http://www.medic.chalmers.se/~jmo/CPS/.
This section provides more help with using specific types of portlets.
A toolbar containing action buttons with icons. Here are some of the kinds of action buttons that you can include in the box:
Displays a navigation trail (a sequence of locations) from the top level of the site to the current page.
Bring up the editor for this box to specify the following:
A calendar with monthly events
A Cell Block allows to display several Templets horizontally inside a Page Block.
Information about the current document, i.e. its title, the date of last modification, the name of the creator, etc.
A Macromedia Flash(tm) box with a caption
A box that displays an image. The icon can have a link and a caption.
Bring up the editor to specify the following:
A language selector
The main content area where documents are displayed
A slot containing a group of boxes or portlets.
A generic box that displays actions, folders, an about box, a login box, an info box, etc.
Horizontal tabs displaying folders, actions, etc.
A box that contains a portlet.
A box with an input field to search the site.
Bring up the editor to specify the following:
A theme selector for visitors (cookies must be enabled)
A box that displays plain text or formatted HTML.
Bring up the editor to specify the following:
[TBA]
Questions:
This section gives guidance on how to work with CPSSkins editor and how to define new themes.
Here are some strategies:
First find a theme that has a look (and capabilities) that are reasonably close to what you want. CPSSkins comes with several built-in themes. (1) Enter the portal themes editor. (2) Set a theme as a default, either (a) by clicking on the "Themes manager" button and then using the radio buttons or (b) by clicking on the tool icon in the tab for that theme near the top of the page and then selecting "Set as default".
Next, make a copy of that theme. You can do this by clicking on the tool icon in the tab for the theme you want to duplicate and then selecting "Duplicate" from the drop down menu.
You can now set your new theme as the default and begin customizing it.
Here are some of the things that you can do:
Here is how you can import a theme:
First create your new (mostly empty) theme. Do this in either of the following ways:
Then, click on the tool icon next to the new theme's tab, select "Edit", change the name of your new theme, and proceed to customize it.
Here is guidance for building your new theme:
Understanding workflows means understanding roles. And understanding roles means understanding groups.
A role can be assigned to an individual, i.e. someone who has joined a site. But, a role can also be assigned to a group, in which case, all members of that group will have that role.
In CPS, roles are associated with a document type and a location. So, if you or a group that you are a member of
Here are a few places to look for information:
The easiest way is to find an existing workflow that is similar to what you need, then copy it.
Look in portal_workflow, then click on the Contents tab. When you find a workflow that has some of the capabilities that you need, use the Copy, Paste, and Rename buttons at the bottom of the page to create your workflow. Now you can start editing states, transitions, variables, permissions, etc.
How do you tell if an existing workflow is similar to the one you want to create? Look at the states (under the States tab) and the transistions (under the Transitions tab). Try to determine if there is an similarity (or isomorphism) with the workflow you want to create.
You may need to do this for both sections and workspaces.
In the ZMI, inside your site, click on workspaces, then select .cps_workflow_configuration. specify the workflow that your type should be controlled by within workspaces.
Do something similar inside sections.
Use CPSSkins. If you do not have CPSSkins installed, you will need to install it. For example, you can use portal_quickinstaller in the ZMI.
To change the logo (image) at the top of the page of your CPS site, follow these steps:
Suppose that when an end user visits a specific folder in you site, you want a particular particular document to be automatically displayed. Outside of the CPS/Zope environments, you would name that document index.html, or something similar. Within CPS, this is a little more complex, in part because CPS makes this customizable. First you need to find out what ID is used for the default view of a folder.
To discover what ID is used for the default view of a folder (or any other portal type), do the following:
But, there is a catch. When I tried to change the document ID from within the site's Web interface, I found that CPS changes underscores to dashes. If the same thing happends to you, you will need to change the ID in the ZMI. For example, if the document is in the user's workspace, you can find the document object under the user's name in workspaces.members.