Skip to content

Bika Lab Systems

Sections
Personal tools
You are here: Home Help Centre Manuals Managing Content in Plone
Document Actions

Managing Content in Plone

Note: This is the print view with all the Reference Manual pages on one page. The paginated version is available here, if you prefer that.

This Manual is a rough copy of the "The Definitive Guide to Plone" written by Andy McKay. And the full copy can be found at: http://docs.neuroinf.de/PloneBook/

1. Introduction

Introduction to main Plone elements; Content Types, Workflow Roles and Workflow Statusses.

1.1. Introducing Plone

Introduction

A company without a Web site is unthinkable—and most companies and organizations have more than one site. Whether it's an external site for communicating with clients, an intranet for employees to use, or a site for direct client communication and feedback, all Web sites have a common problem—how to manage the content on them. This is a challenge that can often cost organizations large amounts of time and effort. Producing a powerful yet flexible system for these sites that meets ever-changing requirements while growing to meet your company's emerging needs isn't easy.

No matter what the requirements for your Web site are or the amount of content or users, Plone is a user-friendly, powerful solution that lets you easily add and edit any type of content through the Web, produce navigation and searches for that content, and apply security and workflow to that content.

Plone enables you to put together almost any Web site and easily update it. This lets you build content-rich sites quickly so you can gain a competitive advantage. Finally, probably the best things about this system are that it's free and it's open source. With its large and impressive feature set, it's comparable, if not better than, many closed-source content management systems that cost hundreds of thousands of dollars.

Mike Sugarbaker says the following when reporting on the Open Source Content Management Conference (OSCOM) in 2002 for the Mindjack site (http://www.mindjack.com/events/oscom.html):

"I won't do the complete rundown of all the 'competing' open-source content management frameworks. I'll cut to the chase: The winner is Plone. This 'productized' take on the six-year-old web application framework Zope was the package with the most tools, the most professionalism, the most traction, and, above all, the most buzz."

You can find the Plone Web site at http://www.plone.org, as shown in Figure 1-1. To try Plone easily, a demonstration site is available at http://demo.plone.org. There you can quickly and easily add and edit content through the Web. Specifically, you can add events, upload pictures, add documents, and process them all through the framework that Plone provides.

img/3294f0101.png

Figure 1-1. The Plone Web site

1.2. What Is a Content Management System?

What is a CMS

One simple definition for a Content Management System (CMS) is that it's a system for managing content. This is a rather unhelpful definition, so I'll break it down into smaller parts for a fuller explanation. I'll start with a broad definition of content: Content is a unit of data with some extra information attached to it. That piece of data could be a Web page, information about an upcoming event, a Microsoft Word document, an image, a movie clip, or any piece of data that has meaning to the organization deploying the system.

All these items are called content, and they all share similar attributes, such as the need to be added or edited by certain users and be published in various ways. A system called workflow controls these attributes. Workflow is logic defined by the organization's business rules, and it describes a system for managing the content.

Historically there has been a difference between document management systems and CMSs, but mostly these two systems have converged. The essential difference is the items being managed; it's often considered that content is any unit of information, and a document refers to something that's created and edited by humans using software such as Microsoft Office. Take, for example, a book: A book contains many units of data and may require management slightly different from that required by content. However, in most cases, this is a small difference, and products such as Plone are able to manage the small units of a larger piece of content and reassemble them.

With the ubiquitousness of the Web, many CMSs are now classified as Web CMSs, either because they have a Web-based interface or because they focus on a Web-based delivery system over the Internet or an intranet. Plone provides a Web management interface and Web-based delivery system.

The following is one definition of a CMS (http://www.contentmanager.eu.com/history.htm):

A CMS is a tool that enables a variety of (centralized) technical and (decentralized) nontechnical staff to create, edit, manage and finally publish a variety of content (such as text, graphics, video, and so on) whilst being constrained by a centralized set of rules, process, and workflows that ensure a coherent, validated Web site appearance.

1.3. Do You Want a Content Management System?

Advantages of a CMS

Although not the only advantage of a CMS, the most obvious benefit of a CMS is coordinating a Web site easily. Take a situation where one person, a Webmaster, coordinates a Web site, either an intranet or an external site. Content comes from users in a variety of formats, and the Webmaster turns these into usable Web pages by converting them to Hypertext Markup Language (HTML). If a user has to change those pages, then the user sends the changes to the Webmaster, who changes the pages, and so on.

This presents many problems for the organization, the biggest being that all content is flowing through one person - an obvious bottleneck. That one person can do only so much work, and if that person is sick or leaves the company, a great deal of productivity is lost in finding a replacement. The publishing process can be quite frustrating as e-mails fly between the Webmaster and the user trying to get content published.

What's needed is a system that does the following:

Separates the content of a page from the presentation: If the actual content is separate from the presentation method, then the content author doesn't need to know any HTML or how the page is delivered. In fact, one piece of content could have many different templates applied to it, including formats other than HTML, such as Portable Document Format (PDF), or Scalable Vector Graphics (SVG). When you want to change the look and feel of the site, you have to change only that one template rather than all the content.

Allows certain users to add and edit content: If specified users can add and edit content easily, then there's no need to send content to the Webmaster or Web team. Instead, the user who wants to create a page can do so and edit it as much as necessary.

Applies rules to whom can publish what and when: Your business rules might not want just anybody publishing content on your Web site; for example, people in marketing would be able to publish to the press release part of the site and not to the engineering section.

Can apply business rules to content: If a person from marketing creates a press release, somebody in legal might need to review that document. In this case, the document will be passed through a review process that ensures it won't go live until these reviews are done.

Can search and index information intelligently: Since the CMS can keep track of structured information about the content (such as author's name, publication date, modification dates, categories, and so on), it can produce listings of content by author, recent content, and so on. It can also provide searching capabilities that are much smarter and more useful than just a simple textual search.

Although this example portrays paybacks that are more significant for large organizations, organizations of all levels benefit from this approach. In fact, typically small organizations that don't employ a full-time Webmaster can be one of the key beneficiaries of such a system. By installing a CMS, you can resolve all these issues and more.

The key factor of any CMS is that it provides a clear separation of the key elements in it: security, workflow, templates, and so on. For example, the templates presenting an item are separate from the content. This allows you to easily modify the presentation.

1.4. Introducing Plone's Features

Plone Features

Plone is open source, licensed under the General Public License (GPL), which is a common open-source license that allows anyone to use the source for free. For more information about the GPL, go to the Free Software Foundation Web site at http://ww.gnu.org. You can examine any aspect of Plone's code and alter it to fit your application. There are no licensing fees to pay, there's no license that will expire, and all the code is visible. This open-source philosophy means that Plone already has a large user base and legion of developers, usability experts, translators, technical writers, and graphic designers who are able to work on Plone. By choosing Plone, you're not locked into one company; rather, nearly a dozen companies offer different Plone services.

Packaging

Plone maintains easy installers for Windows, Linux, and Mac. Other third-party products and add-ons also come with the installers. Maintaining quality releases of these products makes installation and management easy. Also, each new release maintains migration paths and updates so that your Plone site will keep working and stay up-to-date.

Internationalization

The whole Plone user interface is translated into more than 20 languages, including Korean, Japanese, French, Spanish, and German. Inserting your own translation is easy (see Chapter 4).

Usability

Plone offers an excellent user experience that provides high levels of usability and accessibility. This isn't just a matter of presenting pretty HTML but instead goes to the core of Plone. Plone provides an interface that's compatible with the industry and government standard WAI-AAA and U.S. Section 508. This allows sites built with Plone to be used by people with vision disabilities. In addition, this provides the unexpected but related benefit that your page may index better in search engines such as Google.

Skinnable

Plone separates the content from the actual templates used to present the content, often called skins. The skins are written in the excellent HTML templating system, Zope Page Templates, and a large amount of Cascading Style Sheets (CSS). With little knowledge of Plone, you can apply multiple skins, achieve multiple looks, and totally customize your Web site's appearance.

Registration and Personalization

Plone features a complete user registration system. Users register with a Plone site using their own username, password, and any other information you might want to add about the user. You can then personalize the whole user interface for that user. In addition, with add-ons, you can use information you already have about users, coming from many places, such as relational databases, Lightweight Directory Access Protocol (LDAP), Active Directory, and more. Chapter 8 covers how to register and configure users.

Workflow and Security

Workflow controls the logic of processing content through the site. You can configure this logic through the Web using graphical tools. Site administrators can make sites as complex or as simple as they'd like; for example, you can add notification tools such as sending e-mails or instant messages to users. Chapter 8 covers workflow in great detail.

For every item of content in a Plone site, you can set up access control lists to decide who has access to that item and how they'll be able to interact with it. Will they be able to edit it, view it, or comment on it? All this is configurable through the Web (see Chapter 9).

Extensible

Since Plone is open source, it can be easily altered. You can change and configure almost any aspect of Plone to suit your needs. Countless packages and tools for Plone provide a wide array of options for smaller sites and for large-scale enterprises. Repositories of free add-ons for Plone are available at http://www.plone.org. With development tools such as Archetypes (covered in Chapter 13), you can generate and alter Plone code easily through the Web or using Unified Modeling Language (UML) tools. Chapter 10 covers integration of Plone with enterprise solutions such as LDAP, Apache, Microsoft Internet Information Services (IIS), Macromedia Dreamweaver, and so on.

Content Customization

Users of a Plone site can add all manner of content, but the data added isn't limited or constrained. Plone developers can create their own content types so that almost any type of content can be managed; the only limit is your own imagination. In Chapters 11 and 12, I'll discuss how to customize the content types. Chapter 13 will introduce Archetypes, which is a very powerful system for generating content types that don't require programming; for instance, you can generate new types of content from UML tools.

Documentation

The Plone project maintains documentation, including this book, which is published under the Creative Commons license. The best starting place for the community documentation is at http://www.plone.org/documentation.

Community

One of the best things about Plone is the community of developers and companies that supports and develops Plone. With more than 60 developers involved to some degree in the project around the world, it's almost always possible to find a Plone developer online who is willing and able to help you. Alan Runyan, Alexander Limi, and Vidar Andersen started Plone; however, it quickly grew into a thriving open-source project as more developers became involved. The contributions from these developers form the Plone product that's now available.

Example Plone Sites

Many Plone sites exist; some are obvious because of their looks, and some aren't. The following is just a small sample of the more diverse sites:

Plone (http://www.plone.org) Plone Demo Site (http://demo.plone.org) Zope.org (http://www.zope.org) Liquidnet (http://www.liquidnet.com) Design Science Toys (http://www.dstoys.com) Give Kids the World (http://www.gktw.org) Propane (http://www.usepropane.com) Maestro Headquarters (http://mars.telascience.org)

More Plone sites are available at http://www.plone.org/about/sites, including sites that provide a quite different user interface. Without knowing about the development of these sites, it would in fact be hard to tell that these sites use Plone.

2. Logging in to Plone

Joining a site, enabling cookies and setting up your preferences

2.1. Joining a Plone Site

When you join a Plone site, you create an account on the server.

That account gives you the right as a member to add content such as images, documents, and so forth. To join a site, click the join link in the top-right corner of the Web site (see Figure 3-1).

img/3294f0301.png

Figure 3-1. Clicking the join link in the top-right corner of the page

This will take you to a registration form that you'll have to complete (see Figure 3-2). Because this is the first Plone form you've encountered, take note of the following:

  • Some fields are required; a little red box next to the text indicates the required fields.
  • For most fields, some grayed-out help text beneath the field name indicates what you should enter.
img/3294f0302.png

Figure 3-2. The registration page

NOTE Because many of the Plone pages are quite large, the figures in this book have been cropped to show only the key parts (in this case, the form) and not the Plone logo or the footer. These elements are still there, but they're superfluous.

To complete the form, complete the fields that are reasonably obvious. The values of the fields are as follows:

Full Name: Enter your full name. This field is optional.

User Name: Enter the username you want to use. Most people choose an alphanumeric value without spaces, such as bob or jane97. This username will be used throughout the Web site to refer to you. This field is required.

E-mail: A valid e-mail address is required. This will allow the site administrator to contact you and to send a password to you. You can change this e-mail address later by editing your member preferences. This field is required.

Password and Confirm Password: This is the password you want to use; it must be more than four characters and can contain letters, numbers, and the underscore (_) character. Passwords are case sensitive (in other words, SomePassword isn't the same as somepassword). These fields are required.

Send a mail with the password: Check this box if you'd like your password sent to the e-mail address you provided. This field is optional.

Once you've completed this form, click Register to submit your information. If you've made any errors on this form, then you'll see a message at the top and the key fields that have an error highlighted. In Figure 3-3 I entered a password but didn't enter a value for the Confirm Password field. Again, this is the standard way that Plone forms will show errors to you.

img/3294f0303.png

Figure 3-3. Errors on a form

If you've completed the form correctly, then you'll be given the option of logging in immediately. Click the Log In button to log in. You'll see the page shown in Figure 3-4.

img/3294f0304.png

Figure 3-4. After registering

If you already have a username and password or are returning to a site you've previously joined, then you can enter your name and password in the boxes in the left column of the site and click the Log In button.

2.2. Enabling Cookies

To log into a Plone site, you must have cookies enabled. If you access a Plone site and try to log in with cookies disabled, you'll get a friendly message telling you that cookies must be enabled with a link to more information. To enable cookies, perform the following steps, depending on your browser.
Internet Explorer 6.x
  1. Select Tools > Internet Options.
  2. Click the Privacy tab at the top of the screen.
  3. Move the slider to Medium, and click OK.
Internet Explorer 5.x
  1. Select Tools > Internet Options.
  2. Click the Security tab at the top of the screen.
  3. Click Custom Level, and scroll down to the Cookies section.
  4. Set Allow Per-Session Cookies to Enable, and click OK.
Internet Explorer 4.x
  1. Select View > Internet Options.
  2. Click the Security tab at the top of the screen.
  3. Click Custom Level, and scroll down to the Cookies section.
  4. Select Always Accept Cookies or Prompt Before Accepting Cookies, and click OK.
Mozilla 1.x
  1. Select Edit > Preferences.
  2. Find Privacy & Security in the menu on the left. If there’s a plus sign (+) to the left of Privacy & Security, click it.
  3. Select Cookies under Advanced.
  4. Select Enable Cookies for the Originating Web Site Only or Enable All Cookies, and click OK.
Opera
  1. Press F12.
  2. Click Enable Cookies.
Netscape Navigator 6.x
  1. Select Edit > Preferences.
  2. Find Privacy & Security in the menu on the left. If there’s a triangle pointing to the right next to Privacy & Security, click it.
  3. Select Cookies under Privacy & Security.
  4. Select Enable Cookies for the Originating Web Site Only or Enable All Cookies, and click OK.

If you forget your password at some point, you can get it sent to the e-mail address provided when you registered with the Plone site. To have your password mailed to you, click the Forgot your password? link located in the left column of the Web site. This will bring up the forgotten password form, as shown in Figure 3-5; enter your login name, and a password will be e-mailed to you.

img/3294f0305.png

Figure 3-5. Getting a forgotten password

Unfortunately, if you have no longer access to that e-mail account, or you can't even remember the username, you'll have to contact a site administrator. Using the techniques discussed in Chapter 9, the administrator can change your e-mail and find your user account. Once logged in to the Plone site, you'll see a log out link in the upper-right corner. When your work is finished, it's good practice to log out of Plone site, especially if you're accessing it from a computer that's likely to be used by other people.

2.3. Setting Up Your Folder and Preferences

Setting up personal preferences

After you've logged in, the member bar in the top-right corner will change to represent the options available to you as a member of the site (see Figure 3-6).

img/3294f0306.png

Figure 3-6. Your personal choices in the top-right corner have changed.

One of these options is that each member has a folder created for them when they join a site. This folder is set up with particular security so only that member (and administrators) can add and edit the content in that folder. To access your personal folder, click the my folder link in the personal bar in the upper-right corner of the site. In the upper-right corner you'll also see a my preferences link; clicking this will open a list of personalization options. You'll see two choices at the moment; you can change your password, or you can go to the personal preferences and change key preferences in your site.

The change password form allows you to change your password. To complete the form, give your current password and the new password twice. After you've changed your password, the change will be immediate. You don't have to log in again; just remember your new password when you return.

The personal preferences form allows you to set a number of preferences that change how you see the site. These preferences are stored on the server so they're retained between uses of the site (see Figure 3-7).

img/3294f0307.png

Figure 3-7. Changing preferences

The options are as follows:

Full name: This is the full name you gave when you registered with the site.

E-mail: This is the e-mail address associated with your membership and is used a number of places in a Plone site. Most important, if you lose or forget your password, this is the address to which the system will send it.

Content editor: When editing complex content, you may want the help of an editor. If your site administrator has made one available, you can select it here. It will then be used when you click the edit tab of an object. If you're unsure, leave this as the default.

Listed status: This property specifies whether your profile will show up on the members tab and when someone searches the members listing.

Editing of Short Names: Objects have an ID or Short Name property that's used for the internal representation of the content object. This also shows up in the item's Web address and the item's Uniform Resource Locator (URL). By default these look something like News_Item.2002-11-16.4102, but you could make it much simpler, such as november_news, by changing the Short Name value.

NOTE When you change an object's name value, anything that references the older name will no longer be valid and will result in the page not being found. It's best not to change the name value after you submit an object for review or link to it from elsewhere. For this reason, I recommend setting this option to No.

Portrait: In larger organizations and in community Web sites, it's useful to see pictures of other members. The Portrait field allows you to upload a picture of yourself. The picture should be 75 by 100 pixels.

Once you've made the desired changes, click the Save button to commit the changes. Now that you've logged in, it's time to start adding and editing content.

3. Adding Content

As mentioned, now that you're a site member, a folder has been created for you where you can store content. Of course, you can add content to any folder that the site administrator has given you the right to do so, but by default every user can add content to their member folder. Each type of content you can add is distinct, and you can edit and view it in different ways. For this reason, Plone references each type of content differently; for example, you can add images, links, documents, and so on. Out of the box, Plone provides the following content types: Document: This is an item that presents some static information to the user. This is the most common type of content added and most closely represents a typical Web page. News item: This is a document that's to be shown under the news tab (for example, a press release). Link: This is a link to another item, which may be internal or external to another Web site. Image: This is an image, such as a .gif or .jpeg file. Event: This is an upcoming event, meeting, conference, or other event. Folder: This is like a folder on a hard drive; this is a folder for putting content into so that it's easy to find later. Topic: This is a grouping of other content. This is essentially a saved search criteria that you can reuse later. Only privileged site users can add topics. File: This is another piece of content such as a movie, sound clip, text file, spreadsheet, compressed file, or anything else you'd like to upload. I'll go through each of these items using the document as an example, showing in detail how to add and edit documents easily and quickly. Using these basic content types, I'll show you how to build a dynamic site through a browser, without doing any programming. Actually, you have many ways of adding and editing content in a Plone site than just through a Web browser. Access via File Transfer Protocol (FTP), via Web-based Distributed Authoring and Versioning (WebDAV), or via scripts is all possible.

3.1. Adding and Editing a Document

Rather than detailing how to add and edit all the different types of content available, I'll cover adding one type of content, a document, in detail. After adding and editing a few of these documents, the approach to adding content should be second nature, and editing other content will be easy. A document is a page of content, usually a self-contained piece of text. Although all items added to Plone are accessible as Web pages, if there's one content type you could think of as a Web page, this is it. The default home page for a Plone site that you've seen already - the now-famous Welcome to Plone page - is one example of a document.

Adding a Document

You have two ways to add any piece of content using a Web browser. First, ensure you're logged in, because only logged-in users can add content. Second, select the my folder link from the top-right navigation bar. This will take you to your home folder, an area that you control. If you're able to add content to a folder, then the folder will show up with the green border around the top (see Figure 3-9).

img/3294f0309.png

Figure 3-9. My content

If the green border doesn't appear, then you won't be able to add content; this border contains the actions you can perform in the current location. In Figure 3-9, you can see that the page shows the contents of the folder, because that's the highlighted tab. Other tabs appear such as view, sharing, and properties for more advanced options. In the top-right corner of the green border, you'll see an Add New Item drop-down menu and a State drop-down menu. Click the Add New Item menu to open a drop-down list of items to add (see Figure 3-10).

img/3294f0310.png

Figure 3-10. Adding a document from the green drop-down menu

To add a new document, select Document. Alternatively, if you look in the body of the page, you can see another Add New Item drop-down box. Again, click the down arrow to open a list of items that can be added and then select the item you'd like to add (see Figure 3-11).

img/3294f0311.png

Figure 3-11. Adding a document from the main folder's content menu

Using the Add New Item list from the green border is a handy menu since it's available most of the time.

NOTE **If you're familiar with Zope, you should never, never, never add content from the Zope Management Interface (ZMI). Depending upon how you've installed Plone, you may have already seen the ZMI and used it for customizing and developing Plone through the Web. However, adding content through the ZMI will create content items that are incomplete and don't ***Begin Sidebar*

Understanding Where to Add Content

The easiest place to add content at the beginning is in the user's member folder, accessible by clicking the my folder link. Although this is useful, it's probably not the best approach for a long-term solution. Most noticeably it creates long URLs (for example, /Members/andy/Docum....). It also means your content isn't accurately reflected in the navigation tree.

As you'll see later, a few solutions exist for this; the most common solution is to make a folder and give certain users the right to access it. For example, that folder may be Help or News. The 'Using Folder” section later in this chapter discusses adding folders, and Chapter 9 discusses using group workspaces and security.

Editing a Document

Once you've clicked to add a document, you'll be taken directly to the edit page with a message telling you that the document has been created. If this doesn't happen, you can click a document and then click the edit tab. Again, you'll see that the edit tab becomes highlighted in green (see Figure 3-12).

img/3294f0312.png

Figure 3-12. Editing a document

Now you can edit the document in your Web browser, using the form provided. If you look at the URL in the address bar of your browser, you'll note that a short name for the object has been created for you, something such as Document.2003-12-29.43787. The following is a list of the fields and their meanings:

Short name: The short name will become part of the document's URL, so keep the name short and descriptive, preferably without spaces. Keeping to these rules will make URLs easier to read. For example, use something such as audit-report-2003. If you don't provide a name, Plone will create one for you.

NOTE This field won't appear if you selected No for the short names in your preferences page.

Title: This is the title for the item, and it'll be shown throughout the site (for example, at the top of the page, in the search interface, in the title of the browser, and so on). This field is required.

Description: This is a short lead-in to the document, usually about 20 words to introduce the document and provide a teaser for the remainder of the document. This is useful for pages that show summaries of documents, such as search results and folder contents.

Body text: This contains the body of the document. The format for the content is set using the Format field (described next).

Format: You have three choices for the format of body content: Structured Text, HTML, and Plain Text. These types of text are discussed in the 'Choosing a Text Format” sidebar; if you're unsure, leave this field alone and type the body text as usual.

Upload document: If you do have your document as a file on your computer, you can upload it instead of typing the content into the Body Text field. Use the Upload button at the bottom of the page to select a file. The contents of an uploaded file will replace any content in the Body Text field.

Once you've finished editing your document, click the Save button to commit your changes. You'll be returned to the view tab where you can see how the document will be shown to users (see Figure 3-13); to edit it again, click the edit tab.

img/3294f0313.png

Figure 3-13. Saving the content will take you to the view tab.

If you don't provide the correct input on the edit form, when you save the document you'll be returned to the edit page, and your errors will be highlighted. At this point your changes haven't been applied—you must correct the mistakes and click Save again before the changes will be committed. The view tab shown in Figure 3-13 shows the document you've created. You'll see that the title, description, and content are all shown in slightly different styles. At the bottom of the page is a byline that contains information about the author of the document, including the date the page was created.

You'll note that if you go back to folder contents after saving your changes, you'll see two documents in your folder: the existing one that's created for you and the new one you've just added. You can edit either of these documents by clicking them to open the view tab, which allows you to select the edit tab.

Choosing a Text Format

As mentioned previously, you can edit the document content in at least three formats: structured text, HTML, and plain text. This rather confusing state of affairs is brought about by trying to produce easy systems for users to write rich marked-up content in plain text without having to use fancy editors.

Unfortunately, in most cases, this really doesn't work; training is required to understand the formatting. Structured text requires quite a bit of understanding in itself because it has a frustrating syntax and doesn't internationalize well. If I had to pick one format that I'd recommend over all the others, I'd pick HTML because it's widely understood, and you can use What You See Is What You Get (WYSIWYG) editors such as Epoz to produce it.

*HTML* HTML is the most standard format; if a document is entered as HTML, it will be rendered in the same format. This HTML shouldn't be a complete page but rather a snippet. For example:

<p>Here is a sample in <i>HTML</i> for a demonstration.</p>

Ideally the HTML should also be valid Extensible HTML (XHTML) to comply with the rest of the Plone system; if it's not, your pages don't comply with Web standards. Entering text as XHTML isn't for the faint of heart, so in Chapter 9, you'll see how into integrate rich-editing tools into Plone that allow users to easily write content in XHTML. The following screen shot shows Plone using Epoz so users don't have to understand HTML:

img/3294s0301.png

*Plain Text* Plain text is simple. It does no major conversion or manipulation of the text entered; it's just plain text. The only modification made is that new lines are converted into HTML when rendered so that new lines appear in the Web browser. No other altering happens. For example:

Here is a sample in plain text for a demonstration

*Structured Text* Structured text is a system for writing plain-text documents in a particular format, which can then be interpreted in different ways. For example, if a piece of text needs to be highlighted, then it can written as italics; this will then be shown as italics. This series of rules means that a user can write a page that contains formatting information easily. For a full list of structured text rules and examples, please see Appendix A. The following is a sample of structured text:

Here is a sample in *structured text* for a demonstration

Setting Document Metadata

Any piece of content can have any number of properties assigned to it. These properties are known as metadata and provide information such as keywords, copyrights, and contributors of an item.

This entire set of properties is optional and is usually used only if there are special requirements for this piece of content, especially since this information isn't normally shown to the person viewing the content. So the main reason for entering this data is to add information for tasks such as searching or categorizing the content.

You can access properties on an object by selecting the green properties tab. This properties form has the following fields, which are common to all content types:

Allow Discussion: This lets this document be discussed by users who have the right to do so. If the value is left as default, it'll use the sitewide policy for that content type.

Keywords: Each item can have keywords assigned to it to enable grouping and sorting of the items. For example, an article about recent events in politics may have the keywords politics and prime minister. Keywords are flexible, and you can use any keyword from the given list. By default there are no keywords in the Plone system; site administrators may add new keywords so that other users can select them.

Effective Date: The effective date is the first day a piece of content should be available. You can specify this date by entering the values in the form or clicking the little calendar icon, which opens a calendar, and picking a date (see Figure 3-14).

img/3294f0314.png

Figure 3-14. Entering an effective date

Expiration Date: The expiration date is the last day a piece of content should be available. Usually the Effective Date and Expiration Date fields are left blank.

Format: This is the Multipurpose Internet Mail Extensions (MIME) type of the item. The term MIME type refers to a computer definition of the type of content (for example, application/msword or image/jpeg). This is set at a default value; if you're unsure about this field, just ignore it.

Language: This is the language in which the document is written; the default is English.

Copyright: This is the copyright information for the content, which is usually blank.

Contributors: This includes the names of the people outside the Plone system who contributed to the object. Each person's name should be on its own line.

After completing the values for this form, click Save to commit the changes. As stated, usually you won't need to edit the values on this tab. Editing the contents of this tab is usually based upon the requirements for your site and the type of site you're building.

What Are Effective and Expiration Dates?

Any item in the Plone system can have effective and expiration dates if the person editing the content wants. Both of these are optional, and leaving the fields blank will ensure that these values aren't set.

One example of an item that may have an effective date is a press release. In the ideal world, the news item is crafted, prepared, and reviewed in Plone. However, suppose the news item has to go live on the Web site at midnight, but that's exactly when you plan to be sleeping. Not a problem—give the press release an effective date and a time of midnight. Up until the effective date, it won't be visible in the calendar, in navigation, in searches, or in pages that use a search as the listing under the news tab. However, anybody who knows about the press release will be able to access the page directly. Once the effective date has passed, the item will appear in all the aforementioned places and be live to the world.

The effect is similar with expiration dates. If you have a special offer that stops being effective on a particular day, then you could set an expiration date of that day. After that, date it wouldn't appear in calendar, navigation, searches, and so on.

The effective and expiration dates don't actually change the state of the item in workflow (see Chapter 7 for more information on workflow); rather, they just change where it displays. You can also set effective and expiration dates on the state tab, which you'll learn about in the next section.

Publishing Your Document

When a document is created, it's given an initial state, called visible. By default, content isn't automatically published and available to the world; instead, others can view your content, but it doesn't show up in searches or the navigation tree. This is a useful state because you can point other users to this content, but because it won't show up in navigation or searches, it's not visible unless users know about it.

At any point in time, each item of content in your Plone site is in a particular state. This state describes its permissions and roles within the Plone site. By having items in different states, it's possible to apply different security to each item of content. For example, sometimes an item may take a week or two to prepare and involve multiple revisions. Eventually you'll want to publish the content so that it's visible for all users and shows up in the navigation and search.

You can publish the content using the State drop-down menu located at the top right of the main navigation (see Figure 3-15).

img/3294f0315.png

Figure 3-15. State drop-down menu

To publish an object, select Submit from the drop-down menu. By default you can't directly publish content, but you can submit it for review. When an item is submitted for review, it moves into the review state. This is an intermediary state between visible and published. It allows for the review of content by users of your site with the reviewer role, before it goes live for the entire world to see. After you've submitted the content, you'll notice that the content is now in the review state by looking at the box in the top-right corner. You'll also notice that in Figure 3-16, there's no longer an edit tab.

img/3294f0316.png

Figure 3-16. The content has been submitted for review, the state has changed to pending, and the edit tab is no longer an option.

NOTE If you're logged in as a manager, then you'll note there will be one extra option in the drop-down publishing list called Publish. This lets you put content straight into the published state with no intermediate step.

In the workflow drop-down list in the top-right corner, there's also an option for Advanced, which opens the state form for changing the status of an object. This form is the same as clicking the state tab. It has the following fields:

Effective Date: This is the same as the Effective Date field in the properties (see the 'Setting Document Metadata' action).

Expiration Date: This is the same as the Expiration Date field in the properties (see the 'Setting Document Metadata' section).

Comments: This includes any comments you want to make for this change in state that will be recorded in history. For example, you could enter First draft; Bob, please see second paragraph.

Change State: These mirror the choices available in the drop-down menu. For example, the options are Publish, Submit, and so on. One further option, No Change, is available if no change is necessary.

Select the change of state you'd like to occur, and click Save to commit the changes.

What Are the Workflow States?

At this point you may be asking yourself what this workflow thing is and what the states mean. Workflow, as discussed in Chapter 7, is the ability to apply different states to the content. The following are the default states:

Visible: Content is created in the visible state. All users can find visible content through the search function and can access it directly by visiting the object URL. Visible content doesn't show up in the navigation tree. Visible content is editable by their owners and site managers.

Pending: Pending content includes items that have been submitted for publishing by site members. From a user standpoint, pending content behaves like content in the visible state. The difference between the two types is that pending items are flagged for review; site reviewers are prompted to publish or reject pending items. Pending items are editable only by managers and reviewers.

Published: Published items are visible to all site visitors. They appear in search results and the navigation tree. They may also appear in other areas specific to that type (news items, for example, also appear when you click the news tab). Published items are editable only by managers, but owners can retract them for editing (retracting reverts an item to the public draft state).

Private: Items in the private state are visible and editable only by their owners and others with manager access to the folder in which they exist. They won't appear in search results or on the navigation tree for other users. Private items are editable by managers.

How Does Content Get Reviewed?

If you're a reviewer, then in the right column of the home page you'll see a new review list when you first log in. This is a list of the items that have been submitted for review and need reviewing by you or another reviewer (see Figure 3-17).

img/3294f0317.png

Figure 3-17. The review list

The review list will appear on the right when you log in as a user with the review role and there are items to review. In my case, I logged in as admin, which was the user created during my install process. You can tell you're logged in because your name will appear in the member bar. The review list gives a list of items to review - in this case, you need to review the test document. Click the document to open the item. At this point you essentially have the following choices for this item:

Reject it: Reject it by selecting Reject from the drop-down choices. This will move the content back into the visible state and assumes that as a reviewer you're unhappy with it. Usually you may want to click the Advanced option to open the comments form and add some comments stating why you're rejecting it.

Approve it: Approve it by selecting Publish; this will change the content into the published state. This will make the content publicly available.

Do nothing: Leave it by doing nothing. This leaves the content in limbo but sometimes happens when you need to check information or talk to others. Eventually you should return to do something with this content because it'll continue to show up in your list of items until you make one of the previous actions.

Edit it: Edit it, and then perform one of the previous actions. As the reviewer, you can make any change you'd like to do, so feel free to change the content by using the edit tab.

Once you've moved content out of the review state by publishing or retracting it, it will no longer show up in the review list. Of course, this assumes you do have someone as a reviewer for your site; this usually (although not necessarily) is also the user who created the Plone site as an administrator. In Chapter 8, I'll discuss how to add and edit users and give some users the review role.

How Do You Edit a Published Document?

Once a document has been published, it must be retracted to be edited. To do this, select Retract from the workflow drop-down menu, which will move the item back into the visible state. Once it has returned to the visible state, you can reedit it and placed it back into the review queue.

This step, although a little annoying, is necessary to ensure that all content goes through a review step. For example, you have to ensure that any edits made to a page are appropriate by reviewing the content. Users with the manager role can edit the content at any time, so they can quickly go in and fix a typo without having to go through the review step. It's assumed that users with a manager role are trustworthy! If you're a manager, as defined in Chapter 9, you can go to any piece of content and will see the edit tab. At that point, click Edit to alter the document and make your changes.

Sharing Your Document

This allows you to assign more rights to other users or groups of users of the system to your document. This is an advanced feature and is covered in more detail in Chapter 9.

3.2. Adding and Editing Images

I've just covered how to add and edit documents in detail. All the other content types are similar. They all have the same or similar actions to edit; it's just the forms and the data in them that change. In the following sections, I'll cover some of these other types of content. All the following types of content use the same workflow process, so they need to be published in the same manner as documents.

Images are graphical pieces of content; you add them by selecting Image from the drop-down list. When you add an image, the name of the content changes to the file of the image. So, if you upload an image called photo.gif, it'll be accessible in Plone as photo.gif. When adding or uploading a new image, you can select the image from your hard drive by clicking the Browse button and selecting the file (see Figure 3-18).

img/3294f0318.png

Figure 3-18. Uploading an image

It's common for image filenames to end with an extension such as .gif, .jpg, .jpeg, .png, or .pict. You can display images inside Plone on a Web page without having to download them to the local computer if the type of the image uploaded is viewable in the user's Web browser. The most common image types are .gif, .jpg, and .png, which are visible on almost computer system. Figure 3-19 shows an image of the Plone logo.

img/3294f0319.png

Figure 3-19. Viewing the image

You can't edit images directly; instead, you can edit the image on your hard drive using any program, such as Adobe Photoshop or GNU Image Manipulation Program (GIMP). Once complete, clicking the edit tab allows you upload your new image into Plone. If you do a lot of image manipulation, you can refer to Chapter 10, which covers External Editor, a tool that lets you edit images using a program without having to upload and download them.

 

3.3. Adding and Editing a File

Shows how to add a file (attachment)

A file is any arbitrary file that can be uploaded from your hard drive. To add a file, select File* from the drop-down list. On the edit tab, you'll see an Upload button that lets you pick the file from your hard drive. This could be any sort of item, including a plain-text file, a Microsoft Word document, a Microsoft Excel spreadsheet, an executable program, an Adobe Acrobat document, and so on. When you add a file, the name of the item in Plone changes to the name of the file uploaded. So, if you upload a file called *book.pdf, it'll be accessible in Plone as book.pdf. Figure 3-20 shows a plain-text file.

img/3294f0320.png

Figure 3-20. Adding a plain-text file

If the file is recognized as being text, then the contents of the file are shown in the Web page and are editable through the edit tab. Otherwise, the file is downloadable, and users must download it to their local hard drive and edit it there. Afterward they can upload it to the system. You'll note that a file object also has an extra download tab that lets you directly download the file.

3.4. Adding and Editing an Event

This page shows you how to add event in Plone

An event can be something that will happen in the future or something that happened in past. You can add events to Plone, and they show up on the calendar. To add an event, select Event from the drop-down list. An event has more information than most Plone objects; however, most of it is self-explanatory (see Figure 3-21).

img/3294f0321.png

Figure 3-21. Adding an event

As usual, the only required field is Title; however, if you want the event to show up in the calendar, then you must provide a start and end time. Events can span multiple days or be in the past—as long as the start date is before the end date. To enter a date, select the appropriate dates from the drop-down menu, or click the little date icon to open a graphical date picker.

Once the event is published, it'll show up in the calendar. Moving a mouse over the item in the calendar will show the start and end dates for the event, as well as the event's title (see Figure 3-22).

img/3294f0322.png

Figure 3-22. Viewing events in the calendar

3.5. Adding and Editing Links

Shows how to add a link

Link content types are the primary way for users to share links. These URLs can be resources on the Internet or an intranet, an internal resource, or anything to which the users have access. To add a link, select Link from the drop-down menu.

If you're going to link to an Internet resource, you should preface your link with the suitable protocol (for example, http://). For instance, if I was visiting an interesting page on the BBC's Web site and wanted to share this, I could add a link. The value of the URL will be the text in the address bar (for example, http://news.bbc.co.uk), as shown in Figure 3-23.

img/3294f0323.png

Figure 3-23. Adding a link

3.6. Adding and Editing a News Item

Adding a news item

News items are commonly used in Web sites to display news that's of interest to the reader. Actually, a news item contains the same information as a document. The only real difference is that a news item will show up when a visitor clicks the news tab (once the item is published), as shown in Figure 3-24.

img/3294f0324.png

Figure 3-24. A list of news items

If I wanted to write a Web page that was going to be relevant for a long period of time, such as directions to my company's office, I'd use a document. If I wanted a page that detailed my exciting new product and drew attention to it, I'd use a news item. That news item would be visible under the news tab, and as new things happened, it'd slowly move down the page.

4. Organizing Content

So far you've seen how to add and edit content in a Plone site, but without clear organization, this can become a mess quite quickly. You have two main ways of organizing content: folders and topics. A folder is the simplest and most powerful mechanism for organizing content and works just like a folder or a directory on a computer's hard drive. A folder can contain any item of content; content can be copied and pasted between folders, and of course folders can contain other folders. To organize content that's spread all over a site, a more sophisticated and less-used tool called a topic is available. A topic searches your Plone site and finds all objects that match a certain criteria, allowing you to group lots of disparate content.

4.1. Using Folders

How to use folders to manage content

A folder is just like a folder or a directory on a hard drive, except that the folder and its contents exist inside Plone. You use a folder the same way; when you need to categorize content or make things a little clearer, you can group items and place them in a folder. To add a folder to your site, select Folder from the drop-down list. This will add a folder and take you to the edit properties page for that form. A folder has just three rather simple attributes that a user can edit: Name, Title, and Description. I've discussed all these attributes for documents, and nothing is different for folders.

Folders have two green tabs that represent slightly different views: contents and view. Actually, you may have already noticed that there's a contents tab accessible from any piece of content that you've added to the site; for example, when you were editing a document, the contents tab was there. That contents tab will always take you to the contents for that folder.

Viewing the Contents of a Folder

The folder has the concept of a default page, which is a page that will be shown to the user when they view a folder. It's a concept taken from Web sites where viewing a folder on a Web site shows a default page if one is present; often that default page's name is index.htm or index.html. If a folder has a default page, then clicking the view tab will show that default page. If the folder doesn't have a default page, then it'll show a folder listing of all the content in that folder. When looking for a default page to display, Plone looks through the folder for content with a certain name and shows this item. The page name is usually index.html or index_html; however, the site administrator can add or alter these names.

This contents view of a folder allows a user to perform a variety of tasks, such as move content, rename it, delete it, publish it, and change the order it's listed. As shown in Figure 3-25, you'll also see a simple table of the folder contents. Each row of the table shows the title of the content (plus an icon), the type, its size, when it was last modified, its current workflow status, and order selectors. On the left is a checkbox to select the items you want to change and a series of options across the bottom: Rename, Cut, Copy, Delete, and Change Status. These functions are all pretty self-explanatory, and you can apply them to multiple objects at once by clicking several checkboxes.

img/3294f0325.png

Figure 3-25. Contents of a folder after I've added some of the content types described in this chapter

For example, to quickly rename a piece of content, click that item's checkbox and then click Rename. This will open the rename form and allow you to rename the title of each item in that list. Click Save to have the changes take effect. The Cut and Copy buttons allow you to copy or move content between different folders. The Delete button allows you to delete the item from Plone. Just like on your hard drive, if you copy, move, or delete a folder, all the contents of the folder will also be moved, copied, or deleted.

A new feature in Plone 2 is the ability to change the default order of items in a folder. By default, items in a folder will display in the order the items were added. If one item is more important and needs to be moved to the top, use the arrows on the right side of the table to move the item. The following features will appear in the folder contents only when certain things happen:

  • If the content has an expiration date set and it has expired, you'll see the word expired appear in red next to the item.
  • If the server has External Editor installed, you can click the pencil to edit in External Editor (this is covered in Chapter 10).
  • If the content is locked, you'll see a lock icon appear next to the content.
Publishing a Folder

Folders have a much simpler workflow than documents. Earlier in this chapter you saw how to publish content to make it publicly visible because this allows users to create and edit content as much as possible before pushing it live. However, folders are a little different because they contain content but don't have any content of their own. For this reason, folders have no review state. Anyone can directly publish or make private folders, so there are three states: private, visible, and published.

After adding a folder, select Publish from the drop-down list. Then it'll show up in the navigation. As per the earlier rules for workflow, if you don't publish a folder, it won't show up in the navigation.

4.2. Using Topics

Discussed the use of topics

A topic allows you to collect content from disparate places throughout a Plone site and provide it in one location. Topics work by creating a criterion that's common to all the objects you'd like to gather. This criterion could be all images or all news items with Plone in the text. Because topics are a rather complicated type of content, only managers can add them initially. If you can't see Topic in the list of items to add, then you don't have the permission to do so.

To add a topic, select Topic from the drop-down list. After adding the topic, you can create key criteria on the criteria tab. The list of criteria and types is available in the drop-down box at the bottom of the page. This is a rather confusing list; I won't try to discuss it here. Unfortunately, what those terms are and what they mean is based heavily on the underlying technology, such as catalog indexes and object attributes. For this reason, Chapter 11 covers this in detail.

For example, to create a topic that shows all the images, you need to add a criterion that searches for content based on portal_type. For this, select a field name of portal_type, select String Criterion, and then click Add. These criteria will be added to the top of the page; in the field to the right of portal_type, enter Image, and then click Save. You now have criteria for your topic that will show all content that's an image. Returning to the view tab, you can now see all the images on a site.

As stated, topics are quite complicated, have a rather unfriendly interface, and are recommended for only advanced users. Many people have found topics useful, which is why they're still available in Plone; however, a more user-friendly system will be developed in the future.

5. Discussing and Finding Content

Adding and editing content in Plone is much more useful if people can find and then discuss the content. The primary ways users find content is through searching and navigation. Fortunately, Plone automatically sets up searching and navigation for the users, so it's easy to find the content you've added.

5.1. Adding Comments to Content

Discussion on Comments

Feedback from users is a vital part of any Web site. By allowing users to add comments, you ensure that users can give feedback, correct typographical errors, or otherwise discuss the content. You can discuss almost any piece of content in Plone; folders and topics are the only exceptions.

You can enable discussions in one of two ways. First, the owner of the content (otherwise known as the person who created it) turns on the discussion feature by clicking the properties tab of the object and selecting Enabled under the Allow Discussion on This Item header, as shown in Figure 3-26. Second, the default option applies the policy for that type of content as defined by the site administrator; setting this option is described for the administrator in Chapter 10.

img/3294f0326.png

Figure 3-26. Enabling discussions

Once discussions are enabled, click the Add Comment button to discuss the content, which opens a form for adding the comment (see Figure 3-27).

img/3294f0327.png

Figure 3-27. Adding a comment to a piece of content

Enter the subject of the comment and the text of the comment. The text is entered as plain text, so just type away as usual. Comments don't go through any workflow, so comments show up as soon as they've been added. Once a comment has been entered, it can be replied to, forming a threaded list of comments on an item. Further, comments will be entered in the catalog so they can be searched.

NOTE Administrators logged in as managers can remove any replies or entire threads. Disabling replies doesn't remove the comments; it just stops them being shown, so reenabling comments will show the existing comments again.

5.2. Searching for Content

Searching explained.

Plone contains a powerful search engine system based on Zope's ZCatalog. This search engine allows content to be cataloged in multiple ways and to be queried efficiently and quickly. Chapter 10 covers the internals of how this works and how it can be queried.

When you're searching for content, the content will be shown to a user if it's one of the two states: published or visible. At the top of your Plone site a search box provides an easy way to do simple textual searches in the same way as a search engine (see Figure 3-28). For example, enter Tuesday to find all content that contains the word Tuesday. A result of all matching content will display; click the title to get to the content.

img/3294f0328.png

Figure 3-28. A search for Tuesday on Plone.org

The search provides a quite sophisticated search, with features similar to most search engines. You can make this simple query quite complex. For example, you can use the following options:

Globbing: You can use an asterisk to signify any letters. For example, entering Tues* matches Tuesday and Tuesdays. You can't use the asterisk at the beginning of a word, though.

Single wildcards: You can use a question mark anywhere to signify one letter. For example, entering ro?e matches rope, rote, role, and so on. You can't use the question mark at the beginning of a word, though.

And: You can use the word and to signify that both terms on either side of the and must exist. For example, entering Rome and Tuesday will return a result of when both those words are in the content.

Or: You can use the word or to signify that either terms can exist. For example, entering Rome or Tuesday will return a result of when either of those words are in the content.

Not: You can use the word not to return results where the word isn't present; a prefix of and is required. For example, entering welcome and not page would return matches for pages that contained welcome, but not page.

Phrases: Phrases are grouped with double quotes (' ”) and signify several words one after the other. For example, entering 'welcome page” matches This welcome page is used to introduce you to the Plone Content Management System, but not Welcome to the front page of my Web site.

Not phrase: You can specify a phrase with a minus (-) prefix. For example, entering welcome -'welcome page” matches all pages with welcome in them, but not ones that match the phrase welcome page.

NOTE All searches are case insensitive.

Large sites may have a lot of results, so only 20 results display at a time. To page through the results, navigation bars will appear at the top and the bottom of the search result pages. The values on an object used in a search are its title, description, and body text (if the content type has any—for example, news items and documents).

5.3. Performing an Advanced Search

Advanced Search in Plone Explained

You can narrow down the search results by using an advanced search, which is accessible via the search results of a standard search. In old Plone sites, a search tab brought users to this page; you can reenable this tab if you want, as covered in Chapter 4. The advanced search form enables a user to query content using a number of attributes, including title, keywords, description, review state, creation date, content type, and even author, as well as the search text (as used in the quick search available from the top-right corner), as shown in Figure 3-29.

img/3294f0329.png

Figure 3-29. Advanced search

Although the search text field searches both the title and description, you may want to search the description or title only. For that reason, these fields are presented on the advanced search form. You can't search the title and description using the wildcards, globbing, or any of the advanced search options. Any search result will match the input (if given) of all the fields; the results will be an intersection of all the terms.

6. Managing Workflows

One of Plone's many strengths is the workflow component. Workflow fits into one of the core themes of content management, which is the separation of logic, content, and presentation. This chapter therefore covers Plone's workflow in detail. The chapter starts by covering some key definitions related to workflow, as well as the key tools involved, so that you can begin to conceptualize workflows. Once these concepts are clear, I then discuss how to add and edit your own workflows. Throughout this chapter, I reference simple changes you can make to the workflow that comes straight out of the box with Plone. I also provide a series of examples to help you perform tasks such as creating notifications, moving content, and so on. Finally, I show some of the more advanced features of workflow development and some of the useful tools that are available.

6.1. What is Workflow?

Workflow explained

Workflow is a chain of actions or events that occurs on something to achieve an objective. Workflow often expresses business rules that may exist. Every business has different rules and policies about tasks that must happen within that company. Examples of this include the following:

  • Before an employee's time sheet is approved, it must be viewed and acknowledged by a supervisor.
  • In a widget factory, for each widget assembled, users must be notified of the order and any change in the state of the widget as it passes through the factory.
  • Before a Web page is published on a Web site, it must be approved by marketing, approved by the Webmaster, and translated by a linguist.

Workflow separates the logic of these business rules and standardizes the concept of thinking about these changes. By having separate logic, it's now easy for businesses to change the application to fit their business and their business rules. Often applications try to enforce a workflow on a business because the workflow is hard-coded into the application.

6.2. Understanding Workflow in Plone

Plone's workflow tool provides certain features and limitations that are key to understanding workflow in Plone. The workflow product used in Plone is DCWorkflow, which is an open-source product released by Zope Corporation. Other workflow systems are available, and some of them are being incorporated into Plone, such as OpenFlow (http://www.openflow.it). However, for the moment, DCWorkflow is powerful and simple enough to provide all the functionality most users will need. DCWorkflow assumes there's one object in the system that's the target of the workflow-for example, one piece of content or one widget. It further assumes that all objects of the same type go through the same workflow. By repurposing content (see Chapter 11 for more on this), you can have similar content use different workflows. Since the DCWorkflow system is included in Plone, there's nothing extra to install. It's represented in the Zope Management Interface (ZMI) by the portal_workflow object.

Conceptualizing a Workflow

Before explaining a workflow, I'll explain a few simple pieces of terminology: states and transitions.

A state is information about an item of content at a particular moment in time. Examples of states are private, public, pending, and draft. All workflows have at least one starting state in which all the content starts. The workflow will then move the content through a series of states, either by user interaction or by some automation process. When the content reaches an end state, it'll remain in that state for a long time (usually forever). Content may reach one or more different end states in the process of a workflow.

For that piece of content to move from one state to another, a transition is needed. A transition connects a starting state and an ending state. A transition can have lots of different features associated with it, as you'll see later, but for the moment, you just need to know that a transition moves content between two states. Usually a transition is triggered by some external force, such as a user clicking a button on a Web page or a script interacting with a page.

Visualizing a workflow, especially when talking about something as nebulous as content, can be a little confusing. Thinking about an everyday occurrence will help. In this case, the following example shows the workflow of my credit card bill, which I have the joy of getting every month:

  1. The credit card company prepares a bill and mails it to me.
  2. I get the bill and put it on my desk. Sometimes the bill sits on my desk for quite a while as I wait for the end of month. Occasionally I have to query people about certain expenditures, such as "What were those clothes you bought?"
  3. Any serious queries or questions then go back to the credit card company, perhaps causing a new bill to be created (although this happens quite rarely).
  4. Usually at the end of the month, when I do all the accounting, I then pay the bill.

From this, then, you can come up with some states. Looking at the previous steps, you'll see you really have no need to create different states for receiving the bill, which includes opening it and putting it on my desk. Similarly, you don't need to bother with every review that happens. Although these are all valid steps that take place, trying to make a workflow for every state would be too cumbersome. Instead, you can summarize the workflow with the following states:

  • Draft: The credit card bill has been prepared and sent to me.
  • Review: The credit card bill has been received and is on my desk, being reviewed.
  • Paid: The credit card bill has been paid, put in my filing cabinet, and forgotten about forever.

Now that you've come up with the states, you can think of the changes that need to occur. For each of these states, you'll have at least one transition that occurs to move the bill from one state to another:

  • Post: The bank sends the credit card bill.
  • Pay: I pay the credit card bill.
  • Reject: Something is wrong on the bill, and it isn't approved.

Figure 8-1 shows this set of transitions and states. In the figure, boxes represent states, with the state written in them. Arrows represent the transitions from one state to the next, with the name of the transition in italics.

img/3294f0801scrap.png

Figure 8-1. A simple state machine for paying credit card bills

You've now extracted this business process of paying a credit card bill into a workflow. The next step is to think about roles and security for this credit card bill. This workflow now contains the business logic for an application for processing credit cards.

6.3. Understanding Roles and Security in Workflow

In any complicated system, you'll have users of all roles and groups. These roles give Plone a large amount of flexibility with security, but they also can make it more complicated. The next Chapter covers security, local roles, and groups, but this section covers some key points about how these topics relate to workflow.

When a piece of content moves from one workflow state to another, the workflow process can change the security settings on that content. The security settings determine what user can perform what action on what piece of content. By manipulating the security settings through workflow, you can cause the security to change on a piece of content through its life cycle. Users from static systems or Zope often get confused because in Zope, all pieces of content have the same security settings throughout their life cycle.

Returning to the credit card example, you can infer the security settings for the credit card bill. One way to represent this is to produce a table that expands the security in general terms for the transitions that can occur at each of the various states, as shown in Table 8-1.

Table 8-1. The Transitions and Entities That Can Make Them

State Me Bank
Draft   Post
Review Pay Reject
Paid    

At this stage in Table 8-1, you've seen the transitions and who can make them. You haven't thought about the access that each user has to perform an action on an object at each point. For example, at which point can someone edit the bill, and when can it be viewed? These are called actions in Plone terminology, as shown in Table 8-2. I hope that only I have access to my own credit card statements! Likewise, at any stage, the bank is able to view the credit card bill and answer queries on it.

Table 8-2. The Actions and Entities That Can Make Them

State Me Bank
Draft   View, Edit
Review View View
Paid View View

Actually, as it turns out, I can't edit my credit card bill; only the bank can. I can send back my credit bill by rejecting it, but the bank is unlikely to want my edits. In this situation, assume the bank is the owner of the credit card bill. This demonstrates a concept called ownership. I may have several credit card bills from several banks, and in each case you can think of the bank as the owner. Each bank owns its own credit card bills, but Bank A isn't the owner of Bank B's bill. Table 8-3 combines the transitions and actions, changing the terms Me and Bank to Payee and Owner, respectively.

Table 8-3. The Transitions and Actions Combined, plus the Roles of People

State Payee Owner
Draft   Post, View, Edit
Review Pay, Reject, View View
Paid View View
Of course, this is a rather contrived example, but it illustrates how you can apply workflow to basic states. More transitions can occur here-for instance, I'd be more than happy for someone else to pay my credit card bill for me-but that's so unlikely that you shouldn't add it to the workflow or security.

Before showing how to create and edit workflows, I'll now show you the default workflows that ship with Plone.

6.4. Introducing Plone Workflows

Plone ships with a set of default workflows for your Plone site. These workflows provide a logical way of moving content through a P