How OC Customized Drupal
[Note: this article was written in 2005; while much of it is still valid, OC performed many additional customizations to civic space in 2006, including the development of our own custom theme and a three-tiered menu structure.]
OC began using version 0.8.0.3 of the CivicSpace software in December 2004. We were able to perform basic tasks, like picking an appropriate theme (colors, fonts, spacing) and creating some basic pages/stories. However, due to the general lack of good documentation for Drupal, we didn't really understand the full power of the software until we received some assistance from former members of the Dean campaign web team (see credits below) and some labor activists.
In retrospect, what we needed to understand early on was that Drupal is not just an online community tool or a news posting engine. It is actually a fairly sophisticated "online publishing system" that can configured to manage collaborative efforts led by organizations, like ours, that have members, volunteers, and affiliates. Online community sites typically grow to the point where they are difficult to manage, or useful only to die-hards. Our primary base of users -- who work at very small nonprofits -- would not have time to cull through thousands of separate posts or web links.
Thus we needed to understand ways that Drupal can be used to organize information to make it more accessible. And we needed to understand ways to reduce the amount of superfluous information that Drupal would display to site visitors. This article describes some of the things we have now figured out that are enabling us to customize Drupal to achieve these goals.
I should note here that the things we are doing with the Civicspace distribution of Drupal can generally be done with Drupal itself. Civicspace is basically Drupal in a package that is a bit easier to install. In my opinion, the more advanced features of Civicspace (like CiviCrm) are either too new, or are changing too rapidly, for a small organization to easily adopt. Thus, the comments below (for our current 0.8.2 installation of Civicspace with the CiviCrm features turned off) apply just as easily to Drupal.
Understanding the OC Site
The basic site consists of a content area that publishes short 'teasers' to longer articles or posts contained within the site. All authenticated users of the site have the ability to post materials, though some articles may go through editorial review.
In Drupal, material to be posted is structured in a number of very important ways:
* All material has a content type. The types of content appropriate for the front page are primarily of the type 'story' or 'event' or 'blog post'. In addition, some of the content in the site is of type 'book page' or 'web link' -- these are more specialized types of content.
* All material has a date it is posted.
* All material is associated with the user who posted it.
* All material can be assigned to content categories. The content categories are user defined, so we created categories appropriate to what OC is doing.
The power of Drupal is that you can set up pages (or use built in pages) that display different views of your information, in a way that is customized to suit what your nonprofit needs.
The most common kinds of views are built into Drupal. For example, you can very easily create pages that display all posts by a specific user (blogger), or of a particular content type, or posted in a certain time period (i.e. recently), or most importantly, in a particular category. When you use Drupal to generate pages such as these, the system will automatically generate two separate ways to view the information in these pages:
a) a human-readable, attractively formatted view
b) a machine-readable view, provided to allow your information to be extracted and viewed elsewhere.
The common name for the machine readable format is "RSS" (Really Simple Syndication). RSS links are pretty common on the web these days; on the oc-tech.org site these are now indicated by an oranged icon labeled "XML".
What makes Drupal powerful is that there are several ways to allow site administrators and a number of users to work independently creating posts that share categories. An RSS feed is generated automatically for each category. Thus, if eleven different community organizations contribute their tips on using the web to raise funds and assign them the category "online fundraising", it will be possible to easily view all the tips organized into a chronological table of contents, with links that direct the viewer back to the OC site.
The machine-readable "XML" links -- known in web publishing lingo as "feeds" -- enable this table of contents to appear on other sites, with links back to the home site. At the same time, Drupal provides many ways for the administrator of a site to display these dynamic tables of contents on the home site itself.
For the OC site, the links, for a human viewable and computer viewable page for the "online fundraising" category are:
http://organizerscollaborative.org/taxonomy/term/26 (and) http://organizerscollaborative.org/taxonomy/term/26/0/feed
Human and computer viewable links to lists of web links or articles or events which are relevant to advanced users, for the OC-tech.org site, are at:
http://organizerscollaborative.org/taxonomy/term/50 (and) http://organizerscollaborative.org/taxonomy/term/50/0/feed
There are many other links generated automatically, and the administrator of our web site can now make modifications as needed to more readily provide access to content that is of interest to the constituency we serve.
Other Customizations
You will notice that we decided to make the site a two column site, by limiting the number of sidebar "blocks" we turned on, and by setting all of these blocks to appear in the left column.
You will also notice that we tweaked the default theme box_grey that came with Drupal, to make it more attractive. Line spacing, font size for headlines, and the level of darkness of the page were problems initially; we fixed those as a stopgap measure, and we will have a graphic designer come up with something even more attractive in 2006.
Special Customizations
Besides setting up categories and adding content, we needed to do a few things that were not possible with standard Drupal.
1) The "Recent blog posts" blogs block in Drupal is hardwired to ten items. We initially did not use blogs too much, so we wanted to deemphasize this block by making it smaller. The line of code we changed is in modules/blog.module:
$block['content'] = node_title_list(db_query_range(db_rewrite_sql("SELECT n.nid,
n.title, n.created FROM {node} n WHERE n.type = 'blog' AND n.status = 1
ORDER BY n.created DESC"), 0, 7));
2) The flexinode module would only show 128 characters for the 'title' field; this applied to us because the text that appears after content of the type 'weblink' is often 200 characters or more, to describe the link. The line of code we changed in in modules/flexinode/field_textfield.inc:
return form_textfield(t($field->label), $fieldname, isset($node->$fieldname) ? $node->$fieldname : $field->default_value, 60, 255, t($field->description), NULL, $field->required);
3) We didn't want the title text on the home page of the site to be the same as the name of the organization. In Drupal the name of the organization can be defined by going to the page http://oc-tech.org/admin/settings , and it is 'Organizers' Collaborative' for this site. We wanted to add the text 'Community Site' after this, but only have that appear at the top of the home page. To accomplish this, we edited the page generation file in the theme we are using, which is called page.tpl.php, within the box_siddharth theme folder:
<h1 id="site-name"> <a href="<?php print url() \?>" title="Index Page"> <?php print($site_name) \?> Community Site</a></h1>
4) The display of events was kind of ugly... the date display contained information about Greenwhich mean time and the actual end time for events, with minutes and seconds included. We wanted to simplify that, and also remove the word "Description:" from the description of the event.
The first change involved some customizations to the file modules/events/event.theme. We basically rewrote the function theme_event_nodeapi:
function theme_event_nodeapi($node) {
$output = '<div class="event-nodeapi"><div class="'.
$node->type. '-start">'. $node->start_longformat;
if ($node->event_start != $node->event_end) {
$output .= ' If you try this, you might noticed that we used a function that is not defined in Drupal by default. We had to create this function within the file event.module for the customization to work... if you reach that point and you want our customization, email us, we want to hear from you!
The second change involved removing the word 'Description:' from the display of the event description. To do this we needed to modify the flexinode module. The function changed was in modules/flexinode/field_textarea.inc:
function theme_flexinode_textarea($field_id, $label, $value, $formatted_value) {
$output = theme('form_element', '', $formatted_value);
$output = '<div class="flexinode-textarea-'.
$field_id .'">'. $output .'</div>';
return $output;
}
By making all these changes, we have made our site more attractive than it would be using the standard Drupal. We could not have done this if Drupal was not an open source software program. Of course, each time we upgrade the Drupal code we will have to make these code changes all over again. That is, unless we submit improvements to Drupal that will allow some of these customizations to be part of the core system to begin with.
Credits
Alison Stanton, then a student at Miami University in Ohio, assisted us in configuring the features that have become the core of this site: the book module and the content categories (also called 'taxonomies').
Alison was assisted by student intern Siddharth Jain, then a student at SUNY New Paltz, and Aldon Hynes, a blogger who works with political campaigns in Connecticut.
We also thank OC member Steve Dondley and OC volunteer Eric Hopp, who have helped us get through some early roadblocks.
All PHP code modifications were made by Rich Cowan of the OC staff, Greg Dennis of the OC Board, and OC volunteer Ethan Winn.
