The popularity of content-management applications has been growing for years. When the dot-com boom started, everything was about e-commerce and shopping cart this and shopping cart that. When the newness started to wane, people were left with a lot of content on their web sites, but no means to maintain the code other than to hire a staff full of Hypertext Markup Language (HTML) jockeys to cut and paste it for them.
The goal of content management is to addresses the problem of maintaining up-to-date information in a system that enables content contribution and delivery, content deployment, and content maintenance. A good content-management solution should give real-time content updates, revision tracking, and content archiving. It should also enable users to maintain the state of their content within the context that it is displayed without leaving the web site to visit a clunky management portal.
Well, that's a picture of an ideal world where the grass is always greener on your own side of the fence. Rather than go into too much detail about the content-management wish list, let's start with a couple of the major components of content-management systems. There are two main components to any content-management mechanism:
Access to content describes how authenticated users are able to access content for adding, editing, or creating new content. Access to content goes hand-in-hand with our discussion of authorization in the first section of this chapter.
Content workflow describes the processes of creating, approving, and publishing content to an application. Each phase of content workflow might be made up of several steps in itself.
Building an Application for Content Management
Building a simple content-management application is pretty straightforward. Let's say that we're going to build content management into the news portion of the InsideColdFusionMX.com web site. Updating existing content might be as easy as creating an update template that authorized users can launch from a link on the news template. This simple link is an example of how a user gains access to content for management purposes.
The real complexity comes into play when you have multiple users who must review or approve the content before any changes are committed. However, before we go too far into the complexities of content workflow, let's start off with a very basic approach to how users can access content that they are responsible for managing.
Access to Content
We said earlier in our content-management wish list that it is always nice for users to be able to create and maintain content without being forced off to some clunky content administrator portal. Of course, a clunky content administrator portal is very practical sometimes because it enables you to create an undeniable separation between the code and logic of your web site or application and the maintenance application that supports it.
Authentication and authorization play a major part in how we model the development of our content access. Authentication, of course, assures us that only valid users can log in to the application. Authorization enables us to show special content to authenticated users who have a role that enables them to see and interact with that content. Therefore, users of certain roles can view a link to add content to our application while others cannot. Of course, the first rule of authorization is authentication.
Remember the news portion of our site from the previous section? Let's look at some practical code, as shown in Listing 17.7.
Listing 17.7 A Simple Content-Management Implementation
<cfquery name="getNews" datasource="#application.dsn#"> SELECT * FROM News </cfquery> <p>This is the news area for Inside ColdFusion.</p> <table width="100%"> <cfoutput query="getNews"> <tr> <td> <table width="100%" cellspacing="0"> <tr bgcolor="f2f2f2"> <td >#getNews.NewsTitle#</td> <td align="right">#getNews.NewsStartDate#</td> </tr> <tr> <td colspan="2">#getNews.NewsBody#</td> </tr> <tr> <td></td> <td align="right">Contributor: #getNews.NewsSource#</td> </tr> <!--- THIS IS WHERE WE ALLOW THE USER TO ACCESS THE CONTENT ---> <cfif IsUserInRole(5)> </cfif> <tr> <td colspan="2" align="right">[ <a href="/admin.cfm?function=add">add new content</a> ] [ <a href="/admin.cfm?function=edit&item=1256">edit this content</a> ]</td> </tr> </table> </td> </tr> <tr> <td><hr size="1"></td> </tr> </cfoutput> </table>
By executing the code in Listing 17.7 we should see the options to add new content or edit the current content, as in Figure 17.4.
Figure 17.4. User authorized to view, edit, or add content .
The processes associated with editing the content can be simple forms where all the information is accessible and editable on a single page or screen. The editing process can consist of multiple steps. These steps are associated with each other and form what some of us call "process logic paths," a term that we acquired from our time working with Macromedia's Spectra product. Although not a front-line product anymore, Spectra employed some solid concepts related to content creation and management.
Creating content can be as simple as adding a single piece of information to a database table. Most of the time, however, our content tends to be much more involved. We can create content using a single form and a single action page, or we can spread our content collection across several forms, placing the values that we collect into a session structure, which is a temporary table in a database. We can also pass them all along as form variables.
Listing 17.8 is an example of a very simple screen that enables us to add data to our database. Of course, we must be authorized to see the link to add new content for this code to execute.
Listing 17.8 Simple Content Creation Form
<form action="/business_code/act_create_news.cfm" method="post"> <table> <tr> <td valign="top" align="right">Title: </td> <td> <input type="text" name="NewsTitle" maxlength="100"> </td> </tr> <tr> <td valign="top" align="right">Desciption: </td> <td> <textarea name="NewsDesciption" cols="50" rows="3"></textarea> </td> </tr> <tr> <td valign="top" align="right">Body: </td> <td> <textarea name="NewsBody" cols="50" rows="5"></textarea> </td> </tr> <tr> <td valign="top" align="right">Start Date: </td> <td> <input type="text" name="NewsStartDate" maxlength="100"> </td> </tr> <tr> <td valign="top" align="right">End Date: </td> <td> <input type="text" name="NewsEndDate" maxlength="100"> </td> </tr> <tr> <td valign="top" align="right">Source: </td> <td> <input type="text" name="NewsSource" maxlength="100"> </td> </tr> <tr> <td valign="top" align="right">Comments: </td> <td> <textarea name="NewsComments" cols="50" rows="3"></textarea> </td> </tr> <tr> <td colspan="2" align="right"> <input type="submit" value="Create News Item"> </td> </tr> </table> </form>
When we execute the code in Listing 17.8, we see a screen similar to Figure 17.5.
Figure 17.5. Simple content-creation form.
Some transactions are more complicated and require multiple steps in the entry process. You are required to collect values from the form input on each screen, hold them temporarily, and then commit only those values to the database upon completion of the entire process. How you handle the retention of the values that you collect is up to you. Keep in mind, however, that you don't want to do too much juggling of values, which is what you might have to do if you pass values from form page to form page.
I recommend that if you have more than two collection pages that you do not pass the values along as form variables. Keep in mind too that values stored in hidden form fields are visible when you view the source that is returned to the browser. In addition, your code can become more and more complex and less readable with each additional step in the process. You might want to place the values from your form into a session variable that you can clear at the end of the transaction. If you do pass the form values from screen to screen, you might consider passing the entire form structure as a single hidden variable.
The editing process is much like any editing process using HTML or ColdFusion Markup Language (CFML) forms and ColdFusion on the backend to update and delete rows in your database tables. Figure 17.6 shows us a simple form to update the news content that we created through the code in Listing 17.9.
Figure 17.6. Simple content-update form.
Listing 17.9 Simple Content-Update Form
<cfquery name="getNews" datasource="#application.dsn#"> SELECT * FROM News WHERE NewsID = #url.News_ID# </cfquery> <form action="/business_code/act_edit_news.cfm" method="post"> <table> <cfoutput> <tr> <td valign="middle" align="right">Title: </td> <td> <input type="text" name="NewsTitle" maxlength="100" value="#getNews.NewsTitle#" size="64"> </td> </tr> <tr> <td valign="top" align="right">Desciption: </td> <td> <textarea name="NewsDesciption" cols="50" rows="3">#getNews.NewsDesciption#</textarea> </td> </tr> <tr> <td valign="top" align="right">Body: </td> <td> <textarea name="NewsBody" cols="50" rows="5">#getNews.NewsBody#</textarea> </td> </tr> <tr> <td valign="middle" align="right">Start Date: </td> <td> <input type="text" name="NewsStartDate" maxlength="100" value="#getNews.NewsStartDate#"> </td> </tr> <tr> <td valign="middle" align="right">End Date: </td> <td> <input type="text" name="NewsEndDate" maxlength="100" value="#getNews.NewsEndDate#"> </td> </tr> <tr> <td valign="middle" align="right">Source: </td> <td> <input type="text" name="NewsSource" maxlength="100" value="#getNews.NewsSource#"> </td> </tr> <tr> <td valign="top" align="right">Comments: </td> <td> <textarea name="NewsComments" cols="50" rows="3">#getNews.NewsComments#</textarea> </td> </tr> </cfoutput> <tr> <td colspan="2" align="right"> <input type="submit" value="Update News Item"> </td> </tr> </table> </form>
Again, if the editing process had to be separated into more than one step, you'd need to store the form values temporarily until the entire update process had been completed.
Workflow describes the business processes that take place to complete a business task. For example, if you are privy to an interesting piece of news and want to publish it to the InsideColdfusionMX.com web site, you create the news content through the web site. The web site then puts the information in the database and sends me an email. I respond to the email by reading your news item and then verifying it. I then approve the news item, schedule it to be published to the web site, and automatically send you an email upon completion of the scheduling process. Whew…there's a lot to it. That's workflow though. Workflow links individual tasks and the participants that are responsible for their completion. It also identifies which tasks must be completed before others can be started.
Workflows might sound a bit like the process logic paths that we discussed earlier, but they're really not. The difference is that a process logic path is contained within a single business process. Workflows are those business processes tied together.
Defining a workflow is a process that involves several distinct steps. How a workflow looks varies according to the tasks that it involves:
Using the authentication and authorization models that we discussed earlier, we know what roles the authenticated user can play in our workflow. In the preceding example, they can be contributors, editors, or nonparticipants.
Making Use of Existing Components
There is no sense in reinventing the wheel every time you implement a content-management solution (or any other software solution for that matter). It makes sense to make use of existing components in your content-management solution. Many existing components can be found on popular ColdFusion resource sites. One such site is the Macromedia ColdFusion Developer's Exchange at http://devex.macromedia.com/developer/gallery/index.cfm.
Spectra Community Source (Brief Discussion)
Macromedia Spectra is an application framework that is built on Macromedia ColdFusion. Spectra's application framework is designed to combine a set of predefined processes and visual tools that help developers define and build robust web applications. Spectra was designed to make it easy to build and manage Internet and intranet portals that employ content management, e-commerce, and personalized content.
Spectra addresses the full spectrum of participants in the application development and deployment processes. It also enables technical and nontechnical business people to manage web site content. Last, it enables developers to easily create applications that involve complex process logic and workflow. This is done through an easy-to-use visual webtop environment.
ColdFusion developers can jump right into development in the Spectra environment because Spectra is comprised of a collection of ColdFusion custom tags.
Macromedia Spectra is a community source project. Because Spectra is community source, the entire Spectra development community has the ability to contribute to the direction of the product and to the development of product improvements such as patches and code fixes. This type of interaction with the community leads to increased innovation, more frequent updates, and more frequent release cycles.
There are many third-party solutions out there if you do not want to build your own. Recently, the ColdFusion Developer's Journal released its 2001 Readers' Choice Awards. The top three content-management solutions were as follows:
CommonSpot Content Server
PaperThin's CommonSpot Content Server is an out-of-the-box, content-management solution built for web publishing and management of dynamic content. It is designed to get everyone in your organization involved in the creation, maintenance, and publishing of web content.
CommonSpot Content Server puts business professionals in charge of the creation of valuable web content. It's easy-to-understand and intuitive features make it easy for nontechnical users to create, update, and schedule content.
CommonSpot's flexible template and data-driven architecture gives developers and administrators control of the structure and appearance of the site, while simplifying the process of maintaining the content of the site. A roles-based administration and multilevel approval workflow process gives administrators control over the content that gets published.
Because of CommonSpot's open and extensible architecture, developers can customize templates and integrate custom ColdFusion, web, e-commerce and other applications within CommonSpot's content framework.
The list of features for the CommonSpot Content Server goes on and on. Here are some of the more popular:
To find out more about PaperThin's CommonSpot Content Server, visit their web site at www.paperthin.com.
SiteObjects' soEditor is not actually a content-management solution, but a ColdFusion custom tag that is built so that you can easily integrate it into a content-management solution that you have. What soEditor brings to the table is a full-featured, what-you-see-is-what-you-get (WYSISYG) editor for your content areas.
soEditor's WYSIWYG editor has word processor-like features that include the capability to insert HTML tables, images, and links. It also lets you format your text as you see fit.
soEditor's features include the following:
In addition to these standard features, the Professional version of soEditor also offers the following:
To find out more about SiteObject's soEditor, check out their web site at www.siteobjects.com.
Ektron's CMS100 is an entry-level content-authoring and publishing system that is built around another popular Ektron product, eWebEditPro. CMS100 enables business users to author their own web content and incorporate workflow functionality into the content approval process.
CMS100 has the following features:
For more information regarding Ektron's CMS100, visit their web site at www.ektron.com.
Whether content management is just a new buzzword or is here to stay, the concepts of content management can be employed by ColdFusion developers to help them make their world a happier place. Concepts, such as roles-based access to content and content workflow, ensure the integrity of content and that the content that is published has been approved.
Developers can easily create their own custom, content-management solutions using ColdFusion, but there are some cases where it is definitely worth not trying to reinvent the wheel. There are many third-party products out there that you can take advantage of to help make your content-management solution an award winner.