The Slashdot Effect
One of the nicest things about online portals is the amount of user interactivity they offer via their discussion boards and online chat rooms. A prime example of this is Slashdot (http://www.slashdot.com/), which has hundreds of comments on every new topic or article posted on the site; reading them is always an entertaining experience, and they add a wonderful sense of community to the site.
Why am I bringing this up? Because I’ve been playing with Zope a lot lately, and one of my recent projects involved building a Zope-based portal which included a discussion forum.
At first, I thought that I would have to design and build this forum myself from scratch - until a search on Google and Zope.org turned up a very neat little Zope Product named ZUBB, which offered all the features I needed. Installation was a snap, the package was stable, full-featured, and easy to customize, and - best of all - it worked like a charm, allowing me to add Slashdot-type discussion boards easily and transparently to my Zope-based site.
If this is something you’ve always wanted to do, but never known where to begin, this is your lucky day - over the next few pages, I’m going to guide you through the process of installing, using and customizing ZUBB on your Zope portal. Keep reading!
On The Board
First of all, what the heck is ZUBB?
In the words of its author, ZUBB, or the Zope Ultimate Bulletin Board, is “…a threaded discussion board based on ZDiscussion and UBB (Ultimate Bulletin Board).” It provides a simple, user-friendly discussion board for portal members, and includes support for features like message posting and replying, message threading, and subject/body search.
In order to get started with ZUBB, you’ll need a working Zope installation (I’m currently running Zope 2.5.0) and a copy of the latest release (currently version 0.7.1) of the package; you can download a copy from http://www.zope.org/Members/BwanaZulia/ZUBB/
Installation is simply a matter of copying the package files to the appropriate location, and importing the ZUBB package into Zope. Copy the source archive to your Zope installation’s root directory and unzip/untar it. You will see that this archive contains the following files:
__init__.py
__init__.pyc
README.txt
ZDiscussions.py
ZDiscussions2.py
ZDiscussions.zexp
Of these, the first five files should get installed to the <Zope>
/lib/python/Products/ZDBase/ directory, while the last should get installed to the <Zope>
/import/ directory.
Once that’s done, restart Zope and go to the Product Management section of the Zope Control Panel. You should see ZDBase in the list of installed Products.
You now need to import the “ZDiscussions.zexp” package into Zope. Hit the Import button on the Product Management screen, and enter the filename “ZDiscussions.zexp” in the “Import filename” field of the resulting form.
Zope should now import the package and return you to the main Product Management screen.
Make sure that the file is in the <Zope>
/import directory of your Zope installation before performing the step above.
Once the package has been successfully imported, it will show up in the list of installed Products in the Zope management interface.
You can now begin using ZDiscussions on your site.
Putting The Pieces Together
Once you’ve got ZUBB installed, you can use it by creating an instance of the ZDiscussions Topic object in the appropriate location in your Zope site.
Remember to give this topic an ID and a title; this will be used as the subject for the topic thread, and you will not be able to change it later. In this case, I’ll assume that the topic is “PHP versus Zope”
Once the topic has been added, click into it and use the “Regenerate Methods” function (at the top right corner of the page) to create all the required DTML methods for the discussion board.
Finally, view the board, either via the management interface’s “View” function or by accessing the discussion board’s URL in the browser, and you should see something like this:
Speed Post
At this stage, you can post a new message on the topic (each message is referred to as a ZDiscussions item), reply to existing messages, or search existing posts for a particular text string. Posting a message is the fundamental activity here - this message may either be the start of a new thread, or an addition to an existing thread.
In order to post a new message, use the “Post” function that appears near the top of the discussion board.
The resulting form allows you to enter basic user information - your name and email address - together with the contents of your post.
Once submitted, your post will appear in the ZDiscussions discussion tree at the root level (since it is a new message).
In the event that you would like to reply to an existing post, simply click on the message link and use the “Reply” function on the corresponding message page. Again, you’ll be presented with a similar form,
and your message will be attached to the discussion tree at the appropriate node.
Notice how the number of replies to each thread in the discussion board is recorded and displayed to the user - this is an easy way to identify which topics are “hot”, or generating the maximum amount of user activity.
Lost And Found
ZUBB also comes with a fairly adequate search engine, which lets you search for messages either by subject or body. This search engine is accessible via the ZUBB function menu at the top of every page.
This search engine returns a list of posts matching the search term, ordered by date (not thread). Users can then select individual posts to read them, and reply to them if required.
In addition to this, ZUBB also features a fairly cool function named “New Posts” - this provides a list of all the newest messages posted to the board, regardless of which message thread they belong to. This is a quick and useful way of seeing all the new messages that users have added to the board since your last visit, especially if you’re a frequent visitor.
A Custom Job
It’s quite possible that you won’t like the plain-vanilla interface that ships with ZUBB by default. Not to worry - as with all things in Zope, customizing the appearance of the board to your own particular requirements is fairly simple.
ZUBB comes with a default stylesheet named “local_css” - you’ll see it in the folder containing the discussion forum. You can use this default stylesheet very simply, by creating a DTML method named “standard_html_header” and adding the following lines to it:
<html>
<head>
<link rel="stylesheet" href="local_css" type="text/css">
</head>
<body>
Now, the next time you browse to the ZUBB forum, you should see something like this:
You can now easily alter the appearance of the pages by modifying the style rules in the CSS file.
If you take a look inside the folder containing the discussion board in the Zope management interface, you’ll see a large number of DTML methods. Each of these methods contains, in addition to Zope program code, regular HTML formatting instructions that can also be used to alter the layout of the Web pages that make up ZUBB.
Here’s a list of the important methods in the folder
index_html - the home page for the discussion forum
instructions - the instructional text that appears when posting messages
local_css - the stylesheet rules for the forum
postForm - the form used to post new messages, or start new discussions threads
post - the form processor for postForm
new_posts - the list of new posts
replyForm - the form used to reply to existing messages, or add to current threads
reply - the form processor for replyForm
searchForm - the search engine form
search - the search engine form processor
zubb_top_nav - the menu that appears at the top of every ZUBB page
Using the Zope management interface, it’s fairly simple to customize the appearance of each of these elements…and, if you’re familiar with DTML, even alter how they work.
Here’s another example of a ZUBB forum customized in this manner:
Linkzone
And that’s about it for the moment. ZUBB is a very neat little Zope product, one that’s both easy to install and simple to customize and use. If you run (or are contemplating running) a Zope-based Web portal, you should check out this application, and perhaps use it to add a welcome sense of community and interactivity to your Web site.
In case this sounds interesting, take a look at the following links…and, until next time, stay healthy!
The official ZUBB Web page, at http://www.zope.org/Members/BwanaZulia/ZUBB/
More ZUBB installation instructions, at http://www.zope.org/Members/BwanaZulia/ZUBB/INSTALL
Some sample ZUBB boards, at http://www.bwanazulia.com/discussions/ and http://www.freezope.org/forum
ZUBB tips and tricks, at http://www.zope.org/Members/BwanaZulia/ZUBB/TIPS
Note: All examples in this article have been tested on Linux/i586 with Zope 2.5 and ZUBB 0.7.1. Examples are illustrative only, and are not meant for a production environment. Melonfire provides no warranties or support for the source code described in this article. YMMV!
This article was first published on 19 Apr 2002.