Customization and theming

A customization and theming guide for getting more out of your Drupal site. While you can make a fairly nice site using Drupal core modules, in order to leverage Drupal's built in power you should be somewhat familiar with PHP, MySQL and web design.

Included in this section are PHP and SQL code snippets and examples for use in your sites pages, blocks and themes. There are also a few articles on theming engines, which provide the infrastructure to build and create new themes.

Note: Feel free to add handbook pages that are relevant to this section. They go into the moderation queue for review and approval.

Contributed modules

A large number of community created modules allow you to enhance your Drupal system.

You must install and configure each module individually on your machine. Each module download contains specific install instructions. Further description of specific modules' administration and use is contained within. Use modules that have the same version as your Drupal installation.

The following list is just a sample of some useful modules. More modules are added by various people on a constant basis. You can check the latest modules and download them from the Drupal contributed modules project section.

You can keep track of recently created modules by reading Nodes tagged with module term (RSS feed of same) you can also see modules sorted by last update though that page lacks an RSS feed.

NOTE: Not all contributed modules are listed here. Please help by contributing documentation for those that are not. When possible work with the module contributor to ensure accuracy.

Actions: stored procedures for Drupal

The actions module allows the configuration of Drupal actions. A Drupal action is a specially written PHP function whose parameters are configured through the web. For example, the Send Email action has parameters Recipient, Subject, and Message. You could fill in MrFoo@example.com for the recipient, Hi for the subject, and Hello, Mr. Foo for the message to create an instance of the Send Email action. This action instance could then be fired by a module at appropriate times when you want Mr. Foo to get an email.

Actions are like stored procedures that can be loosely coupled with events in Drupal.

Let's examine a ridiculously simple example. Suppose you want to be draconian with your Drupal site's comment policy. Any user who leaves a comment gets blocked immediately. You can implement this quite easily with the comment hook:

<?php
foo_comment
($a1, $op) {
   if (
$op == 'insert') {
     global
$user;
    
// block user here...
  
}
}
?>

What an action does is wrap up this code into a nice package. That package can then be associated with the nodeapi hook. Or some other hook. Actions takes this function, which we'll call "Block current user", and allows you to assign it to any hook-op combination.

We do that by several coding conventions. Here is the skeleton of a simple action:

<?php
/**
  * Implementation of a Drupal action.
  */
function action_block_user($op, $context = array(), &$object) {
   switch (
$op) {

     case
'do':
       global
$user;
      
// block user here...
      
break;

     case
'metadata':
       return array(
        
'description' => t('Block current user'),
        
'type' => 'User',
        
'batchable' => TRUE,
        
'configurable' => FALSE,
        
'supported hooks' => array(
          
'nodeapi' => array(
            
'delete' => 1,
            
'insert' => 1,
            
'update' => 1,
            
'view' => 1
            
),
          
'comment' => array(
            
'insert' => 1,
            
'update' => 1,
            
'delete' => 1
          
)
         )
       );
   }
}
?>

We've implemented two ops. The 'metadata' op describes the action by declaring some things, including what hook/op combinations it supports. The 'do' op is actually where the code runs. We list the 'do' op first in the switch statement for performance, since Drupal will then encounter it first during execution.

The above is a nonconfigurable action. There's nothing about it you can change. It will block the current user and that's that. It's basically a singleton action.

On the other hand, an action like "Send email" needs to know some things in order to run. It needs a subject, and body, a recipient, and such. Configurable actions are not available for use until they have been configured (obviously). They can be configured from the main actions interface at admin/build/actions.

Administration: Create an experience for your users

The administration module provides an interface for site administrators to create a experience for users. The module allows for a full-page interface of the administration menu and can be configured. The default interface for this module is task based to help administrators create accomplish the most common task identified in usability studies. It also includes statistical overview information about the site activities as well as links to handbook pages to address challenging administration tasks.

You can deactive menus.

You can:

AdSense Injector: automatic, no hassle insertion of AdSense ads in node content

The AdSense Injector module allows administrators to specify automatic insertion of AdSense ads into a node full-page view, or, if desired, after teasers in frontpage or taxonomy list views.

It provides centralized control of:

  • Ad format, channel, and group attributes for all inserted ads
  • Full control over allowed node types (for example, you can choose to never insert ads into image nodes, or forum nodes, etc.)
  • MInimum word count control for full-page node views: if a node doesn't have the minimum word count, ads won't be inserted.

AdSense Injector also respects the AdSense module visibility settings - if you have set visibility options in the AdSense module, AdSense injector will insert ads only into the paths you have chosen to allow.

Rationale

Why is this useful? In my experience, this simplifies certain important aspects of ad insertion and placement.

Traditional approaches:

  • Modify your theme's node.tpl.php or other template file(s) in order to inject ads on every node view.
    What happens if you have multiple sites or use multiple themes, or use custom per-node-type template files (node-book.tpl.php, node-image.tpl.php etc)? Now you have to edit, test, and maintain multiple template files, and, if the theme is updated to fix bugs, you have to merge in your changes.
  • Hand-edit each node content and use inline [adsense:x:y] inline filter tags.
    This gives tremendous flexibility in layout, but creates a maintenance nightmare if you should wish to alter your channel or ad layouts site-wide.
  • Use block insertion into the theme's template regions.
    This is great if your theme's regions provide the flexibility you want - it seems that themes vary somewhat in the regions they provide, and those regions aren't always in the places you want - so once again, you are back to tweaking theme template files if you want to place the ads near or in the content.

Usage

AdSense Injector uses (and requires) installation and proper configuration of the AdSense Module in order to function properly. Please install, configure, and test the AdSense module before you install Adsense Injector.

Examples

See it in use at http://exodusdev.com and http://www.roadcarvin.com

Coming soon:

  • Theming/CSS tricks
  • Examples

Configuration

Note: This page describes Adsense_Injector release 2.5 and later

Configuration is fairly straighforward.

Enable the options that make sense (insert in node body and / or on teaser lists), enable insertion on the desired node types, and configure the insertion templates as needed.

The default templates are fairly simple.

One interesting feature as of the 2.5 releases is the ability to insert before and/or after the node teaser or body, and the ad insertion now uses the adsense module filter tag format - in other words, you insert '[adsense:nnnxnn:1:1]' style tags rather than specify ad format in the configuration options. This vastly simplifies the configuration, and, provides maximum flexibility in setting up ad insertion.

Please see the adsense module help and documentation for more information on the filter tag and ad formats available for use.

Installation

Installation is done in the usual way: just drop the module into your selected modules directory and enable the module.

More info here:

http://drupal.org/node/70151

Stupid Template Tricks

Note: This page describes the 2.5 and later releases

Consider the default node insertion template (formatted for readability):

<div class="ad-auto-inserted" style="float:left; margin: 0 1em .25em 0;">
[adsense:120x240:1:1]
</div>
%body
<br class="clear"/>
[adsense:468x60:1:1]

On full node views, this will insert a 120x240 left-floating ad block before the node body, then, after the body text, a 468x60 ad will be appended, both ads using the adsense module's group 1 and channel 1 settings.

Now, then, what else can we do? How about putting an ad on both the left and right side of the top of the node, as well as at the bottom? We can do that very easily, using inline float styles (for the purposes of this example - it's cleaner to use stylesheet-defined CSS rules).

(Yes, this is probably annoying in-your-face advertising, and I wouldn't recommend it, but it serves to demonstrate capabilities.)

<div class="ad-auto-inserted" style="float:left; margin: 0 1em .25em 0;">
[adsense:120x240:1:1]
</div>
<div class="ad-auto-inserted" style="float:right; margin: 0 0 .25em 1em;">
[adsense:120x240:1:1]
</div>
%body
<br class="clear"/>
[adsense:468x60:1:1]

Give it a try.

Obviously, you can play a lot of tricks with the template strings - for example, you can insert any arbitrary text before or after the node body, including html, javascript, etc. The sky (and your imagination) is the limit, just be careful not to break anything. (At this point, the adsense_injector module can do more than just inject ads using the new template scheme.)

Please see the adsense module help and documentation for more information on the filter tag and ad formats available for use.

Archive: view content by date

NOTE: This module has been removed from core as of 5.0

The archive page allows content to be viewed by selecting the day. It also provides a monthly calendar view that users can use to navigate through content.

To view the archive by date, select the date in the calendar. Administrators can enable the Calendar to browse archives block in block administration to allow users to browse by calendar. Clicking on a date in the monthly calendar view shows the content for that date. Users can navigate to different months using arrows beside the month's name in the calendar display. The current date will be highlighted in the calendar.

You can

  • view your archive by day.
  • enable the Calendar to browse archives block at administer >> block.

View an archive by type or by category

Each module that produces content may have a page that lists content of that type. For example all blog posts can be seen at the blog path. Content that has been categorized using taxonomy terms have a page for viewing that content.

Asset: Unify asset file management in Drupal

Placeholder for the documentation of the asset module.

Audio: Uploading and playback of audio files

The audio module allows users to add audio media content to a site. Audio is an important medium for community communication. The recent rise of the podcast phenomenon is an example of the trend towards audio content. The audio module enables music, spoken word, and voicemail messages to be played on a site, and all audio node content is automatically podcast-enabled.

The audio module allows a user to create a new audio post. An audio post lets you uploadand download audio files, and uses the getID3 library to read and write ID3 tag information from the audio file. The getID# library is required. This module comes with a handy flash player that can be embeded in your site, to allow streaming of the audio without allowing downloads. Audio files can be submitted by browsing users computer for files to upload. Audio posts can also be configured to allow the files to be downloaded. Audio administration allows the path for audio files to be uploaded to be configured. The getID3 library can also be configured in audio administration.

You can:

  • listen to the most recent audio files added in your user profile at my account.
  • add an audio file at create content >> audio.
  • enable the latest audio and random audio blocks at administer >> block.
  • administer audio module at administers >> settings >> audio.
  • download and install the required getID3 library from getID3 sourceforge page.
  • file issues, read about known bugs, and download the latest version on the Audio project page.

Add album images to the teaser

If you've got the audio_image module enabled you can attach images to audio nodes. Currently the images are not displayed as part of the teaser. The following code snippet shows how to override the default teaser theme function on a PHPTemplate theme. Add this to your template.php file.

For Drupal 4.7

<?php
function phptemplate_audio_teaser($node) {
 
// make sure that all the allowed tags are included.
 
foreach (audio_get_tags_allowed() as $tag) {
   
$params['%'. $tag] = isset($node->audio_tags[$tag]) ? $node->audio_tags[$tag] : '';
  }
 
$params['%filelength'] = theme('audio_format_filelength', $node->audio_fileinfo);
 
$params['%fileformat'] = theme('audio_format_fileformat', $node->audio_fileinfo);
 
$params['%player'] = audio_get_player($node);
 
$params['%play_count'] = $node->audio_fileinfo['play_count'];
 
$params['%download_count'] = $node->audio_fileinfo['download_count'];

 
// THE CHANGE FROM THE ORIGNAL FUNCTION IS HERE
  // if there's an image, put it in as an %image parameter.
 
if ($image = audio_images_get($node->audio_images)) {
   
$params['%image'] = "<div class='audio-image'>\n" . theme('audio_image', $image) . "\n</div>\n";
  }
 
// THAT'S ALL

 
$format = variable_get('audio_teaser_format', '%player %filelength');

  return
t($format, $params) . $node->teaser;
}
?>

For Drupal 5

<?php
function phptemplate_audio_teaser($node) {
 
// make sure that all the allowed tags are included.
 
foreach (audio_get_tags_allowed() as $tag) {
   
$params['!'. $tag] = isset($node->audio_tags[$tag]) ? check_plain($node->audio_tags[$tag]) : '';
  }
 
$params['!filelength'] = theme('audio_format_filelength', $node->audio_fileinfo);
 
$params['!fileformat'] = theme('audio_format_fileformat', $node->audio_fileinfo);
 
$params['!player'] = audio_get_player($node);
 
$params['!play_count'] = check_plain($node->audio_fileinfo['play_count']);
 
$params['!download_count'] = check_plain($node->audio_fileinfo['download_count']);

 
// THE CHANGE FROM THE ORIGNAL FUNCTION IS HERE
  // if there's an image, put it in as an !image parameter.
 
if ($image = audio_images_get($node->audio_images)) {
   
$params['!image'] = "<div class='audio-image'>\n" . theme('audio_image', $image) . "\n</div>\n";
  }
 
// THAT'S ALL

 
$format = variable_get('audio_teaser_format', '!player !filelength');

  return
t($format, $params);
}
?>

For more info see #78883, the issue that spawned this.

Audio module FAQ

Q: Why does the player stop at weird parts?
A: I'm not really sure. If you're running into this bug please leave a comment on this issue with more information.

Q: Is there an upgrade script for 4.6 to 4.7?
A: Yes, there is read more about on issue #57769.

Q: I don't want to have to upload the audio to my site and waste bandwidth. Can I use remote URLs?
A: No, but it's a feature I'd like to implement.

Q: Why do I have to click the Flash player twice?
A: You're using IE. See #70241.

Q: I can only upload 2MB files or less.
A: If you notice that you can only attach 2Mb MP3's, you need to up your limits. Assuming your host allows this - you need to add a line like this to your .htaccess file: php_value upload_max_filesize 20M or check the upload limitations of your PHP.ini settings.

Q: I screwed something up. How do I completely re-install the audio module?
A: First, you need to remove the audio module's tables:

DROP TABLE audio;
DROP TABLE audio_file;
DROP TABLE audio_metadata;
Next you'll need to remove the record from Drupal's system table that lists the audio module as an installed module. Deleting it means that the next time you enable the module, the install function will be run:
DELETE FROM system WHERE name = 'audio';
After running that query, re-enable the module and check for any errors. The tables should be created.

Audio module review

This module makes use of the wonderful getID3 PHP library for reading and writing ID3 tags for mp3 and other audio files. Creating a new audio file is as simple as creating a new 'audio' node type. The ID3 tags are extracted from the audio file and displayed in the node listing. The title can optionally be automatically set using the ID3 tag information, by default it is artist - song title. The node body itself contains all of the ID3 information for the audio file, with links for each of the fields. This allows a user, for instance, to find all audio files by artist, title, album, genre, and year, by simply clicking the link. Additionally, the length and format of the file are extracted and displayed too. And the best feature, it includes the XSPF Flash player so you can play the audio file right on the website, without having to download! If a user does want the audio file, there is a download link available as well. Additionally, if the ID3 tags are incomplete upon uploading, anyone with node edit permissions can edit the audio node and update the ID3 tags automatically! This module also keeps track of how many times the audio file has been downloaded and how many times it has been played through the website.

Because this audio file is created as a node, all of the wonderful node properties can be used. The most useful would be setting up a category (or a taxonomy) to label the content in this audio file, which can be setup to use 1 or more terms to "tag" the audio file. Each audio file can also be setup so users can post comments on the same page as the audio file as well.

Also, this module adds a link to each user's profile that links to all of their recent audio files, making it very handy to find all audio files uploaded by a certain person.

This review was adapted from a review written on Lullabot.com

Change audio player in 4.7

If you want to make changes to the flash player you can over-ride the theme function. To understand "theme level" and overriding functions in drupal go here. To change the player type you need to make a template file in your theme directory. I use PHPTemplate so the file is called template.php.

The following (assuming you're using PHPTemplate) makes the flash player red:

<?php
// override the colors on the flash player
function phptemplate_audio_mp3_player($node, $options = array()) {
   
$options['b_fgcolor'] = 'cccccc';
    return
theme_audio_mp3_player($node, $options);
}
?>

There are several option values that can be used to control the colors:
  • Background color. If it's not specified, it'll default to transparent. 'b_bgcolor' => "000000"
  • Foreground (border and icon) color. 'b_fgcolor' => "ffffff"
  • Foreground color by state. The order is: connecting (spinner), ready (arrow), playing (square), and ??? (not sure). The b_fgcolor value will be used for any ommitted values. 'b_colors' => "ff0000,,00000ff,000000"
Override to use the Slim player

In the template.php file I put this code which overrides the theme_audio_mp3_player function to use the 'Slim' player:

<?php
function phptemplate_audio_mp3_player($node, $options = array()) {
  global
$base_url;

 
// flash only supports a limited range of sample rates.
 
switch ($node->audio_fileinfo['sample_rate']) {
    case
'44100': case '22050': case '11025':
      break;
    default:
      return;
  }

 
$options = array_merge((array) $options, array(
   
'song_url' => $node->url_play,
   
'song_title' => $node->audio_tags['title'],
  ));

 
$params = array();
  foreach (
$options as $key => $val) {
   
$params[] = rawurlencode($key) .'='. rawurlencode($val);
  }

 
$url = $base_url .'/'. drupal_get_path('module', 'audio') .'/players/xspf_player_slim.swf';
  if (
$params) {
   
$url .= '?'. implode('&amp;', $params);
  }

 
$output = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="400" height="15" id="xspf_player" align="middle">';
 
$output .= '<param name="allowScriptAccess" value="sameDomain" />';
 
$output .= '<param name="movie" value="'. $url .'" />';
 
$output .= '<param name="quality" value="high" />';
 
$output .= '<param name="bgcolor" value="#e6e6e6" />';
 
$output .= '<embed src="'. $url .'" quality="high" bgcolor="#e6e6e6" width="400" height="15" name="xspf_player" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
 
$output .= '</object>';

  return
$output;
}
?>

Next you'll need to download the 'Slim' player from the website here. Transfer these files to the /modules/audio/players/ directory on your server and ensure that the shockwave file is named exactly as at the end of the $url line.

Now refresh your page (force reload by adding a '?' to the end of your url) and now everytime that Drupal tries to use theme_audio_mp3_player, which uses the standard 'button' player it will be overridden with the above code and instead use the 'Slim' player.

If you would instead like to use the 'Full' player then substitute the code after $output with the required code from the XSPF Player website.

Avatar Selection: allows users to pick an avatar from a list

Description

When a user edits their accounts details they can choose to upload an image or photo of themselves, also known as an avatar. The Avatar Selection module allows the user to pick an avatar image from a list already loaded by an administrative user. It is also possible to disable the uploading of pictures by users and only allow them to select an avatar icon from this list.

No images are supplied with this module. It is recommended that all images you use are roughly of the same size.

Configuration

Once the module is activated, go to Administer >> Site configuration >> Avatar Selection (admin/settings/avatar_selection). Here you'll find a form that will allow you to upload or delete images. Users with the 'administer avatar selection' access permission will be able to upload and delete the images.

Current maintainer

Stella Power (http://drupal.org/user/66894)

Avatar Selection - FAQ

Commonly asked questions and problems
My images aren't appearing
If your transfer method is set to "private" on Administer >> Site Configuration >> File System, then you may have problems viewing the avatar selection images. Please ensure that the file system path set is an absolute path and if you've changed your transfer method from "public" to "private" since uploading the images, you may need to re-upload them again. See http://drupal.org/node/92376 for more info.

Avatar Selection - Installation

Install the files

Download the latest version of the Avatar Selection module from the project page. Untar/unzip the files and place the entire avatar_selection directory in an appropriate module directory like sites/all/modules.

Enable the module
  • Go to Administer » Site Building » Modules
  • Make sure "Avatar Selection" is enabled (listed under "Other").
  • Click Save configuration at the bottom of this form.

Avatar Selection - Settings

The Avatar Selection module can be configured at Administer >> Site Configuration >> Avatar Selection. Users will need the 'administer avatar selection' permission to alter the settings and to upload or delete images.

  • Disable users uploading pictures to profile - This allows users to pick their avatar image from the selection provided by this module but prevents them from uploading new avatars when editing their account.
  • Force users to select an avatar image - This only comes into effect on the user registration screen or when image uploads are disabled.
  • Upload image - This adds a new avatar image to the selection. Maximum dimensions are 85x85 and the maximum size is 30 kB. Images must have one of the following extensions (case sensitive): png, jpg, jpeg, gif, PNG, JPG, JPEG, GIF.

To delete an image from the selection, go to admin/settings/avatar_selection/delete and check the box for each image you wish to remove. Then just click on the "Delete" button to finish. There is no delete confirmation message, so please ensure you have the correct boxes checked before clicking on this button.

Avatar Selection - User Permissions

There are just two permissions you can assign a user with the Avatar Selection module.

  • access avatars - users with this permission will be able to view the avatar selection list, and select an avatar from it, when they edit their account details.
  • administer avatar selection - this permission enables users to upload and delete avatar images and alter the configuration settings.

Backup: create an archive of your Drupal database and files

The backup module performs a backup of your entire Drupal website. An archive file, or tarball, of your Drupal database and all your files is created on the webserver. You can then download this file with your web browser.

You can:

  • create a backup tarball at administer >> content >> backup.
  • file issues, read about known bugs, and download the latest version on the Backup project page.

Restoring from a backup

The backup module doesn't have the capability to restore from a backup, as this would involve Drupal having its own files and database pulled from under it as it runs.

To restore a backup archive from a unix / linux command line:

  1. Untar the tarball into your document_root directory. This will recreate the file structure.
  2. Unzip the database file. You'll need to use the gzip program for that.
  3. Re-create the database by typing "mysql < database-dump-filename". Depending on your configuration, you may need to supply credentials via parameters to MySQL as necessary.

Banner: management and display of rotating image banners

The banner module provides a way to manage banners on your site. You can upload images, allow users to upload their own banners, choose to approve banners that are uploaded, choose what URL to link banners to, and track statistics around the display and click-through rates of banners.

Banners are meant to be added either in a custom block or directly to your theme. See the Adding banners to your site section that follows for instructions on how to accomplish this.

Note: this is a work in progress. Please feel free to edit and extend this page.

You can:

  • get info about your banners under the my banners link, as well as add new banners if you have permission.
  • administer all banner settings at administer >> banners, including viewing all banners, editing settings such enabling or disabling individual banners, and adding new banners as an admin user
  • set banner module sitewide preferences at administer >> settings >> banner.
  • file issues, read about known bugs, and download the latest version on the Banner project page.

Adding banners to your site

Starting with version 4.7 of the module, Banners have their very own node type. To add a graphic banner, you need to have the Upload module enabled (graphics are attached to the banner nodes). Also, you will need to add them to a taxonomy term. Click administer » categories and either create a new vocabulary with the "banner" node type or add the "banner" node type to an existing vocabulary. Once you're done, click create content » banner to create a banner.

As listed on the Banner module info page, the banners module provides an interface to manage banners. To actually display the banners on your site, you need to add a small snippet of PHP code in either a block or directly to your theme template.

If you are not comfortable with editing your theme, adding a custom PHP block is the easiest method, but you will only be able to display banners in the sidebar. To add, for example, a banner to your header, you will need to edit your theme.

The banner_display(42,1) function is what is needed to display banners.

The number in parentheses refers to the taxonomy term ID from which you would like to show banners. Banners belong to taxonomy terms, so you will need to know the term ID for which they belong. You can usually find this out by going to administer » categories, then click the "list terms" link in your banner vocabulary to find the IDs for the category you use.

Displaying banners in a custom block

  1. Click administer » blocks then the add tab.
  2. Type in a title. This will be shown to the user as the heading for the block.
  3. Choose "PHP code" as the input filter
  4. Paste in the following code: <?php return banner_display(42, 1); ?>
    • Note: replace 42 with the taxonomy term ID from the category you assigned the block(s) you want to rotate through in this block
  5. Type in a block description. Only administrators will see this.
  6. Click the Save block button

See the Blocks section for more information on working with the placement and setup of blocks.

Displaying banners directly as part of your PHPTemplate-based theme

  1. In your theme's page.tpl.php file where you want the banner to appear, paste in the following code:
    <?php print banner_display(42,1); ?>

As noted above, the number indicates from which taxonomy term ID to display banners. You may add this code in multiple places in your theme, with either the same or different banner group numbers.

Important note: the code is slightly different than that for a block, in that it uses 'print' instead of 'return'.

BBCode: Format text using BBCode

The Drupal bbcode.module adds a BBCode filter to Drupal. This allows you to use HTML-like tags as an alternative to HTML itself for adding markup to your posts. BBCode is easier to use than HTML and helps to prevent malicious users from disrupting your site's formatting.

See the help screen of the module (or the code) for information on which tags and variants are supported. This implementation is not necessarily the same as the original BBCode implementation.

Note that this filter also recognizes and converts URLs and email addresses to links automatically

You can file issues, read about known bugs, and download the latest version on the BBCode project page.

Biblio: manage lists of scholarly publications

The biblio module allows you to create and maintain bibliographic lists of publications. The full (HTML) text of the publication can be included is so desired. Other files such as PDF or Word documents can be attached using the upload module.

Bibliographic entries can be imported from EndNote (versions 7,8,9,10 in XML or tagged format) and BibTex. The bibliographic lists can be formated in a number of styles including: American Psychological Association (APA), Council of Science Editors (CSE) and Institute of Electrical and Electronics Engineers (IEEE).

1) Installation and updating

4.7 and greater
Unpack the module ".tar" file in the Drupal module directory. (Note: It is often advisable to create a "contrib" directory under the main module directory in order to make house keeping and upgrades easier).
Now visit the admin/modules page and enable the biblio module. This will install the required database tables and setup a number of pre-defined
publication types. These types can be changed or deleted on the
admin/settings/biblio/types page.

Updating: Any time you install an new version of the module you should run the update.php script in case there are any database modifications included with the new version.

4.6
Unpack the module ".tar" file in the Drupal module directory, then create the database tables using following command:

mysql -u {userid} -p {drupaldatabase} < biblio.mysql

You will also have to enable the module on the admin/modules page.

2) Configuration

Base URL
This sets the base URL used to access the biblio module (e.g. /biblio ).
Number of results per page.:
This sets the number of results that will be displayed per page.
Restrict users such that they can only view their own biblio entries
This option restricts the users capability to view biblio entries. They will only be able to see the entries which they have created and own.
Footnotes
You can integrate with the footnotes module here.
Integration with the footnotes module
Depends on: Footnotes (enabled)
This will convert tags into tags. This will cause intermingled and tags to be sequentially numbered. For this to work, you must put the filter ahead of the filter in the filter chain. If this option is not set, and tags will be handled separately.
OpenURL
You can set an openurl link here
OpenURL Base URL:
This sets your institution's base OpenURL gateway, which is used to generate OpenURL links. To implement a "Universal" OpenURL system, try using OCLC's OpenURL Resolver Registry gateway: http://worldcatlibraries.org/registry/gateway
OpenURL Image:
Enter a path to your image here, this image will be used as button which when clicked will find the entry via the OpenURL link
Sorting
You can set the default sorting and ordering for the /biblio page here.
Sort by:
Author, Title, Type, Year
Order:
Descending, Ascending
Styling
You can set the default style for the /biblio page here.
Normalize author names when displaying biblio records
Tries (doesn't always work) to reformat author names so that they are displayed in the format "Lastname, Initials" e.g. Smith, J.S. (Note: This setting does not modify the entry in the database, it only reformats it's presentation. This option can be turned off at any time to display the original format.)
Links open in new browser
This causes the Author and Title links to open in a new browser window
Node Layout:
Original
Only Fulltext if available
This alters the layout of the "node" (full) view.
Style: (This alters the layout of the "list" view)
Council of Science Editors (CSE)
American Psychological Association (APA)
Institute of Electrical and Electronics Engineers (IEEE)
Classic - This is the original biblio style
Syndication
You can set the RSS defaults here.
Allow RSS feeds of new biblio entries
This will create an rss feed of the most recent biblio entries. It will be available at /biblio/rss.xml
Number of items in the RSS feed.:
Limits the number of items in the /biblio/rss.xml feed to this number.
Taxonomy
You can set the Taxonomy defaults here.
Use keywords from biblio entries as taxonomy "free tags"
This option allows user to add keywords (free tags) to describe their documents. These keywords will be registered as taxonomy.
Vocabulary:
Select vocabulary (category) to use for free tags.

3) Basic usage

visit biblio/

(more to follow)

4) Advanced usage

(content to follow)

5) Customization

(content to follow)

6) Uninstalling

Drupal 5.x
Disable the module on the admin/modules page, then click on the uninstall tab and select the module for removal. This will remove all of the biblio entries in the node table as well as the biblio tables them selves. NOTE: You will loose any/all bibliographic entries that you have made and this action cannot be undone.
So don't say you weren't warned!
Drupal 4.6/4.7
This is a bit trickier since you must delete all "biblio" type entries out of the node table (and in 4.7 the node_revisions table), then you can drop the biblio tables.

BitTorrent: transfer large files efficiently with peers

The BitTorrent module allows the distribution of large files via the BitTorrent network technology. By sharing the cost of downloading as well as uploading with a network of other users no one site has to carry the burden of every download. This is very important for a network of community sites that want to share media such as podcasts, video blogs, and participatory culture media. BitTorrent should not be used to distribute copyrighted material. It is an open system and law enforcement officials can easily track and prosecute users who attempt to pirate content. This module provides a BitTorrent tracker which coordinates the sharing of content via a map of the content pieces in a .torrent file.

There is a list of torrents that are being tracked. You can set the explanation of BitTorrent for users of your site in general settings. You can also make a list of torrent announce URLs that your tracker will use. This module is not currently being distributed. It was developed by Digital Bicycle and will be distributed by CivicSpace Labs in a manner to avoid its use as a piracy tool.

You can:

Torrent tracker module and torrent node type

Blog Information: User Blog Titles and Descriptions

The Blog Information module gives each user, with access permission, the ability to have their own blog title and description. This is similar to sites like blogger.com blogs.

Once enabled, and the appropriate groups have permission, the user on their edit account page as a new section call Blog Information asking for a users blog title and description. This information is displayed via a block on www.example.com/?q=blog/[user] pages and on blog nodes.

Drupal 5 Version 2.x

In the 2.x version of the Blog Information module there are 2 new features.

  1. Input Formats - The blog description now utilizes input formats.
  2. Customizing the Content - The content section of the block displaying the blog information description can now be themed. This content section of the block is now themed by the theme_bloginfo_block function.

Remove Page Title on pages with Blog Information block

On a blog created by the blog module the page title for the blog reads like "example's blog" where the name (example in this case) is the blog authors username. On these pages you may wish to wish to remove the page title and use the Blog Information block instead.

To do this, in phptemplate, you need to modify your page.tpl.php file. Change:

<?php
print $title;
?>

To:

<?php
if (arg(0) != 'blog' && $node->type != 'blog') { print $title; }
?>

This will not display the $title tag on pages that are /blog or have a node type of 'blog'. On all other pages it will be displayed.

Buddylist: list your social network

Buddy list enables users to add buddies in their social network to their user account. Users can maintain a list of their buddies and keep track of what their buddies are posting to the site. They can also track their buddy's buddies and thereby explore a social network.

You can add buddies via user profiles. The administrator must enable viewing users profiles to be able to use the buddy list option. On the View tab of the user profile, there is a Buddy list section. One of the buddy list actions is Add Buddy. Select this action to add a user to your buddy list. Administrators can also enable the Buddylist block, or Recent Buddy Content. This block allows you to see a list of your buddies and content from your buddies respectively. An administrator can also enable the Friends Of A Friend (FOAF) module to allow for sharing of buddy lists between different social networking applications.

You can

  • add a buddy by looking at user profiles.
  • allow users to view profiles in administer >> access control >> permisions.
  • enable the buddy list blocsk at administer >> block.
  • administer the buddy list block at administer >> settings >> buddylist.
  • file issues, read about known bugs, and download the latest version on the Buddylist project page.

Calendar: Any Views Date in a Calendar

Also see Date documentation.

See the Calendar Project Page to download and install this module. Please report problems on the Issue queue rather than as comments on this page, since that makes the handbook quite messy and hard to read. Plus, many of the problems reported here are already reported or fixed, which you can see in the issue queue. I'm going to start removing comments that are bug reports or support requests from this page and asking you to report them on the issue queue instead. Comments that help clarify the handbook or point out ways that it could be improved are perfectly OK.

Requires Views and the Date API. This module will display any Views date field in calendar formats. Works with CCK date fields, Event module dates, node created and updated dates, and any other Views date field. The module does not create dates, it only displays dates that have already been created elsewhere, like CCK date fields.

Multiple calendars can be created for different purposes, i.e. one that displays node created dates as an archive calendar and another to display CCK dates for a custom content type, just give each a unique url.

You can use the supplied default calendar view as a starting point, or create one or more calendar views from scratch:

Setup

  • Select the Calendar display as the page type for your view. If you want to have a mini calendar available in a block, select the Calendar display as the block type as well as the page type.
  • Add any fields you want to display on the calendar as fields to the view. Be sure to include fields that contain the dates that need to be shown on the calendar. Date fields can include CCK date fields, event start and end dates, or dates like the node created or updated dates. If you use CCK date fields, set them to 'Do not group multiple values' so each value will display in its own date box.
  • Add three arguments to the view: Calendar Year, Calendar Month, and Calendar Day, in that order. Set each of them to 'Display All Values'.
  • Add sorts to the view for each date field so the dates are sorted correctly.
  • In most cases, add a Node: Type filter to filter the view by the content types that contain your selected date fields. The default view has a Node: Type filter that selects all node types. Change it to select only the node types you want in your calendar.

Updating From Earlier Versions

The Calendar module now uses the Date API from the Date module. The Date API was pulled out of the Date module so you can use the API with no dependence on CCK. For anyone updating a previous version of the Calendar module may run into problems on the update since the Calendar module will be installed but the Date API will not. The easiest way to make the transition is to uninstall the Calendar module (and Date module if you are using it) before uploading the latest code to your site, then go to the modules page and enable both Date API and the Calendar module. If you don't uninstall the Calendar module first, you will see some errors when you upload the new code, but it will automatically uninstall the Calendar module until you go to the modules page and install the Calendar module and the Date API module.

Other Features

Switch between year, month, week, and day views with back and next navigation.

A mini calendar is available using the block view if the block view is also set to the Calendar type.

Two other blocks are available. A legend block will display only on calendar pages and will show a legend of the color coding for field names and content types.

A Switch Calendar block will display only on calendar pages and allows the user to switch between calendar, list, table, teaser, and full node views for whichever time period is being viewed. The back/next navigation will remain at the top of the traditional views displays so you can move from one month to the next, for instance.

iCal Import and Export

To use iCal import or export, enable the new Calendar iCal module.

To export the calendar as an iCal feed, add a fourth Calendar argument to your view, the Calendar: iCal Feed argument.

To import iCal feeds from other locations into your calendar, choose the 'iCal' tab you see when looking at your calendar and fill out information about the feeds you want to insert into the calendar.

Combining Calendar and Traditional Views

There was lots of good discussion in the DrupalCon presentation on Date + Calendar. Based on Earl's suggestion to make sure the Calendar arguments will work with any view and requests from the audience for the ability to show a list in the full page and a calendar in the block, or other combinations of calendar and traditional views in the page and block, I've made reworked the argument handling to make the Calendar arguments work independently of the plugin theme.

In the lastest commit to the 5.x and HEAD versions, you can now add calendar arguments to any view with a date field (list, table, teasers, etc) and get date-based back/next navigation just like the calendar view has; you can have a mini calendar in the block view and a list in the page, or any other combination you like. Just be sure the date field you want to use as the filter is listed in the Fields list.

Themeing the Results

Calendar module results can be customized by changing the included css and/or themes. The key theme is located at the top of the calendar.theme file and looks like:

<?php
/**
*  Themeable node display
*
*  appends the field name to the title
*  constructs a teaser out of any non-date fields in the view
*/
function theme_calendar_calendar_node($node, $type) {
  
// Display the regular teaser view for local events.
  
if (!$node->remote && $type == 'calendar_node_day') {
    
$node = node_load($node->nid);
    
$node->teaser = node_view($node, TRUE, FALSE);
    
$node->title = '';
   }
  
// For other views, construct a teaser out of the provided fields.
  
else {
     if (
$node->label && !strstr($node->title, $node->label)) {
      
$node->title .= ' ('. $node->label .')';
     }
     if (
$node->fields) {
       foreach (
$node->fields as $field) {
        
$node->teaser .= '<div>'. $field .'</div>';
       }
     }
     if (!
$node->url && !$node->remote) {
      
$node->url = "node/$node->nid";
     }
   }
  
// Remote nodes may come in with lengthy descriptions that won't fit
   // in small boxes of year, month, and week calendars.
  
if ($type != 'calendar_node_day' && $node->remote) {
    
$node->teaser = '';
   }
   return
theme($type, $node);
}
?>

This default theme will display the node title with the field label appended to it, the date, and any other fields that were added to the view. This 'teaser' will be sent to a theme from calendar_api.inc based on the $type chosen. The types are 'calendar_node_month', 'calendar_node_day', 'calendar_node_week', and 'calendar_node_year'. The theme can be overridden in the same way other themes are, by copying that function to template.php and changing 'theme' to the theme name, then making any appropriate changes.

For instance, if you want different results when looking at the 'day' view, you could add a switch to the above theme based on the type, then if it is a 'day' type, do a node_load() to pick up more node information and print it out, or node_view() to display the complete node.

Debugging

  • If you see things consistently one day off or somtimes missing from a time period they should appear in, it is most likely a timezone conversion issue, so double check the timezone configuration for that item.
  • If you use CCK dates and have them set up with no hours granularity, you must also set the field up to use no timezone conversion. The current version of the Date module requires this, but date fields created with earlier versions may be set up incorrectly. Dates with no hours get the hour set by default to midnight, so any negative timezone conversion will move it back to the previous day.

Step by Step Setup of Calendar View

Why not use the Event module?

Using the Event module is perfectly acceptable, quicker/simpler way to get a basic calendar running on your site. If you need something more flexible/extensible, here's how to create a Calendar view. If you've got other differentiating factors, list them in the comments, and I'll incorporate them here.

How to implement a Calendar View

Using

Install the Modules

Download and extract the modules in your /sites/all/modules directory.
Go to Administer › Site building > Modules and enable:

  • Content
  • Date (under CCK)
  • Date API (under Other)
  • Calendar
  • Views
  • Views UI
Make a custom Content Type to go on you calendar

Go to Administer › Content management > Add Content Type

  • Name=Performance (or "event" or "meeting" or whatever you want to call it)
  • Type=performance
  • Description = Sing, Sing a song...
  • Whatever you prefer for the rest of the form
  • Save the Content Type

Edit the content type again and then select Add field

  • Name = Time
  • Field Type = Date / Selected list (or Date / Textfield with javascript pop-up calendar - if you have jstools enabled)
  • Click "Create Field" and you'll be taken to second form
  • Widget = Selected List (or Textfield with javascript pop-up calendar - if you have jstools enabled)(not sure why you have to select this twice)
  • Label = Time
  • Help Text = whatever
  • Under Data settings:
    Required: checked
    Multiple Values: not checked
  • Input Options
    Granularity: Year,Month,Day,Hour, Minute (but not second) selected
    To Date: Optional
  • Click Save Field Settings
  • Make a Performance so you'll see something on the calendar once it's working

    Create content > Performance

    • Title = Check your calendar
    • From Date = This Friday at 3:00pm
    • To Date = blank
    • Body = Hope I'm doing something fun this weekend
    • Click Submit
    Modify the default calendar view

    Go to Administer › Site building > Views and you should have a Calendar View
    Click Add..

    • The info under Basic Information, Page, and Block are all fine.
    • Under Fields delete the Node: Updated Time
    • Then under Add Field, select Date:Time and click Add Field
    • Next to Time Field, Label can be blank, Handler needs to be Do Not Group Multiple Values
    • Arguments can all be left alone
    • Under Filters ... Add Filter, select Node: Type and click Add Filter
    • Operator = Is one of. Value = Performance
    • Exposed Filters can be left alone
    • Under Sort Criteria, delete Node: Updated Time, and Date: Time (field_time). Leave the Order Ascending

    Click Save and you're back at the Administer › Site building > Views. You should see the default calendar view with an Overridden status. And at the top will be your new calendar view that uses your CCK node called Performance

    Click on the link under URL and you should see your performance on the correct day. If everything looks OK, go back and edit the view again and in the Page > Menu section, check Provide Menu. By default, the menu link will appear in the Navigation menu, but you can move it wherever by going to Adminsiter > Site Building > Menus.

Captcha: spam control

A CAPTCHA is a type of challenge-response test used in computing to determine whether the user is human. This is used in Drupal to prevent spam posts and bot activity.

Installation

  1. Enable the module
  2. Go to admin/settings/captcha to enable captchas for various actions

Related Topics

TextImage
Enable image-based Captchas.
reCAPTCHA
Use the reCAPTCHA web service for Captchas.
Form Store
Allows Captchas to be provided on additional forms.

reCAPTCHA

The reCAPTCHA module uses the reCAPTCHA web service to improve the CAPTCHA system and protect email addresses. For more information on what reCAPTCHA is, please visit the official website.

Installation
  1. Extract the reCAPTCHA module to your local favourite modules directory (sites/all/modules)
  2. Download the reCAPTCHA PHP Library
  3. Extract the files to modules/recaptcha/recaptcha so that recaptchalib.php is available at modules/recaptcha/recaptcha/recaptchalib.php
Configuration
  1. Enable both the reCAPTCHA and CAPTCHA modules in admin/build/modules. Note that the reCAPTCHA module requires Captcha version 2.1 or up
  2. You'll now find a reCAPTCHA tab in the CAPTCHA administration page available at admin/settings/captcha/recaptcha
  3. Register for a public and private reCAPTCHA key
  4. Input the keys into the reCAPTCHA settings. The rest of the settings should be fine as their defaults
  5. Visit the Captcha administration page (admin/settings/captcha) and set where you want the reCAPTCHA form to be presented
Mailhide Input Format

The reCAPTCHA module also comes with an input format to protect email addresses. This, of course, is optional to use and is only there if you want it. For a demonstration of how it works, please see the official website. The following is how you use that input filter:

  1. Head over to your input format settings (admin/settings/filters)
  2. Edit your default input format and add the reCAPTCHA Mailhide filter
  3. Click on the Configure tab and put in your public and private Mailhide keys
  4. Use the Rearrange tab to change the weight of the filter depending on what filters already exist
Resources

Category: structure and classify content

The category module allows you to structure your site into a tree-like hierarchy of pages, and to classify your dynamic content, all within one seamless interface. Gone are the days when these two tasks were carried out using separate and incompatible tools: now it's all one and the same. Built upon the solid foundations of the book and taxonomy modules, the category module overcomes the weaknesses of both these tools, to give you more power than ever before in customizing the navigational experience of your Drupal site.

Documentation, announcements, a live demo, and more can be found on the category module web site. If you're interested, also see why the category module documentation is not here on drupal.org.

You can:

  • create and maintain container and category nodes at administer >> categories.
  • administer general category options at administer >> settings >> category.
  • assign content to your categories by configuring containers to allow certain node types, and then selecting categories for your new nodes on the 'create content' form.
  • transform existing nodes of other types into containers or categories, using the tabs displayed on node pages.
  • file issues, read about known bugs, and download the latest version on the Category project page.

CiviCRM: manage community contacts, relationships, and activities

The CiviCRM module stores information on the universe of people associated with a community and on their interactions such as emails, donations, petitions, events, etc. It can act as a stand alone contact management system or it can be integrated with mass mailer, volunteer management, petition, and event finding. CiviCRM enables organizations to maintain all these activities in a single database, creating efficiencies and new opportunities for communities to better communicate and benefit from relationships with their community members.

The CiviCRM module allows you to create contacts, or import them from other sources. You can record relationships between contacts, such as indicating they live in the same household. There are two types of groups of contacts. You can create static groups which have a set list of contacts. You can also create dynamic (smart) groups based on characteristics that contacts have in common. For example, you could create a group of all contacts who live in California AND who have volunteered for your organization within the past year. The CiviCRM module also allows for tagging for less formal categorization of contacts or groups. You can easily extend CiviCRM to record community member information which is specific to your community or organization using custom fields. For example, you can create a set of fields to track volunteer skills and preferences. CiviCRM profile gives you a way to allow community members ('users') to update their own information, as well as share some of that information with others. Finally, you can configure custom activity types such as volunteering or attending events.

You can:

CiviContribute

CiviContribute allows you to accept donations online via Paypal or Moneris. Additional payment processors can be supported by extending the modular code. Read the CiviContribute Guide for more information.

You can:

  • Track and store any type of contributions (time, money, in-kind, volunteer hours, etc.)
  • Associate custom data with any contribution type.
  • Associate contributions with a central data store.
  • Create an online donation page.
  • Configure possible donation amounts including user entered donation amounts.
  • Customize the text of the donation page
  • Add custom fields stored in CiviCRM to handle data required for political, nonprofit or other specialized donations.

Installation instructions for CiviCRM

CiviCRM installation instructions for installing CiviCRM.

CiviNode and CiviNode CCK: Tools For Integrating CiviCRM Contacts Into Drupal Content

CiviNode is a module and API that exposes CiviCRM contacts, groups, and other CiviCRM object types to other Drupal modules. It's designed to make CiviCRM easier to use and integrate with all of the Drupal tools and techniques you already use to create websites.

Using CiviNode with CCK you can:

  • Add CiviCRM contacts or groups as fields in a Content Construction Kit (CCK) data type. Currently, you can add pop-up menus for both groups and contacts. CiviNode CCK also makes use of CiviCRM's native Dojo widget set to give AJAX-style access to contacts.
  • Restrict a CCK field to contacts from a single group, or pull contacts from you entire CiviCRM data store.
  • Display a contact as a link, a CiviCRM profile (a collection of contact fields), or as a link into CiviCRM.
  • Display CiviCRM-based CCK fields using the Views module.

CiviNode does this via its own API to handle most of the lower level interaction with CiviCRM's native API. It implements hooks for CiviCRM into Drupal's form system and APIs, and implements widgets that developers can use in their own modules. If you are a module developer, this wrapper API for handling common programming tasks can save you time and effort when accessing CiviCRM content in your modules. CiviNode also adds hooks for theming CiviCRM content and generating links from Drupal pages back into CiviCRM contact view pages.

Work on this project is being done by Rob Thorne of Torenware Networks, and been sponsored by the generous support of The Collective Heritage Foundation/Bioneers, the Green Party of Canada, and Openflows Community Technology Lab.

Adding a CiviCRM-based Field to a CCK Data Type

To actually see CiviCRM data inside of Drupal, you need to add a CiviNode widget into one of your CCK data types. Here are some quick steps to get you started:

  1. Go to Admin / Content / Content Types, and either create a new data type, or select one you'd like to add a CiviCRM field to. See the CCK Handbook for more information.
  2. Choose "Add Field". If you've activated CiviNode and the CiviCRM CCK Widgets module, you'll see a couple of new widget types in the "Field Types" section: the CiviCRM Contact and CiviCRM Group widgets. The contact widget comes in two basic "flavors": a "Contact Selector", which is a simple pop-up, and the "Contact Autocompletor", which uses AJAX (i.e., JavaScript) to search for contacts. The Contact Selector is a good choice if you have a small group of contacts you want to assign to a field (say, for a "Group Leaders" or "Staff Assigned" field). Use the Autocompleter if you need to search for one contact out of a large group (say, one voter out of a hundred thousand in a voter information database). If you have ever used the Node Reference or User Reference widgets from CCK, you'll recognize how the Autocompleter works. Hit "Create Field" to continue creating your field.
  3. On the next page see, you configure the field. At the bottom of the page, there are a couple of new options to configure in the "Data settings" section: Default CiviCRM Group, and Default CiviCRM Profile. The default group setting lets you restrict the contacts that a field will display to only those contacts belonging to a CiviCRM group. You will almost always want to choose this option, especially if you use a Contact Selector. The default profile setting lets you control what contact fields from CiviCRM you want displayed. This allows you to control who sees what fields, and helps keep your private data private.
  4. Once you've configured your field, you will probably also want to set up the way the field will display in node pages. Go to the Display Fields section of the Manage Fields page, and choose a formatting option. You can choose to display only a single field of your contact (the default is the "display_name" field), or display the contact as a link into CiviCRM's contact viewing and editing page (you'll need to grant the web user the rights to do see this, of course), or as a Profile. You can set different settings for the Teaser display than for a full page display.

There are a lot more features to CiviNode, and the module is under active development. But hopefully, this will get you started.

Installing and Configuring CiviNode and Related Modules

To install CiviNode into Drupal and create and use CiviCRM content in your pages, you first need to set up CiviCRM and CCK, and you should look at the documentation for those modules elsewhere. If you want to take advantage of CiviNode's support of the Views module, you should install Views as well.

Once you've done that, there are a couple of things you will need to do in order to get started:

  • Download the CiviNode tar ball from our project page, and "untar" it as unusual into your sites/all/modules directory.
  • Activate the module in the Admin / Site Building / Modules. Note that under Drupal 5.x, you can't activate CiviNode unless CiviCRM is installed and active. You should also turn on the Content module for CCK, and the CiviCRM CCK Widgets module (note: the CiviCRM Data module is now obsolete, and is only included for those folks who have data in that format.).
  • You need to have at least one CiviCRM profile defined in CiviCRM. A profile is just a grouping of contact fields you want to display together. You define a profile by going to the CiviCRM / Administer CiviCRM page (follow the link in your Navigation menu) and use the "CiviCRM Profile" tool in the Config section. You can define as many profiles as you like, and use different profiles for displaying various kinds of content on your site.
  • Once you've defined some profiles, you need to tell CiviNode which profile to use as its default. Go to Admin / Settings / CiviNode, and you'll see that your profiles now appear in the setttings page. Select the one you want, and click on Save.

CiviNode is now configured, and we're ready to create CCK fields using your contacts.

Classified Ads: a simple path to self-expiring classified ad content

The Drupal Classified Ads module provides a quick and easy way to host textual classified ads on your Drupal 4.7 or Drupal 5.x sites. If you run multiple sites, or don't want to be bothered with installing flexinode/CCK or other modules to piece together a classified ads system, this may be just the ticket.

This module creates a drop-in, plug-and-play textual classified ad node type (ed_classified) with no need to use CCK or flexinode. This module has been in use on several production sites for a while now. It provides the following features:

  • cron-based automatic expiration (on expiration, the classified ad node is moved to unpublished state, but is not yet deleted/purged so it can be 'renewed') and after an admin-defined 'grace period', previously expired ads are purged (deleted).
  • Expired ad renewal: Users with proper permissions may 'renew' their expired but not yet purged ads during the 'grace period' by checking the 'renew ad' checkbox in the edit form.
  • Simple taxonomy-based browsing similar to that provided by image.module galleries. (I lifted some of the code from image.module, and modified it for use here.)
  • Several useful blocks (latest ads, most popular ads, and stats including total number of unexpired ads and number of new ads in last 24 hours).
  • Per-user classified ads lists (under each user's profile, visible to all users with 'access user profiles' permissions).
  • Administration list of all classified ads, sortable by expiration date, with direct edit link to the ad.
  • Length-limited body text with live, javascript-based counter showing characters used and remaining while user enters the body text - no need to hit submit and wait for an error message.
  • New Feb. 25 2007 Version 5.x-1.5 and 4.7.x-1.5 - Ad expiration varies by taxonomy term. Now you can control ad duration depending on category selection

Overview and rationale at http://exodusdev.com/drupal/modules/ed_classified.module

Project page and official releases: http://drupal.org/project/ed_classified

Live demo site: http://gigs.exodusdev.com - sign in with your drupal user id and start creating ads (and if you are a drupal developer, you can tell the world about your services.)

Paid classified ads may be implemented by installing the lm_paypal module and limiting ed_classified node creation to paying users. Other schemes may work as well, but the ed_classified module does not handle paid ad creation for you - this is beyond the scope of the module at present, although lm_paypal integration is planned for a future release.

Photo ads may be implemented using image.module, upload_image, and other image modules. I use upload.module, image.module and upload_image combined on my sites, and that combination works pretty well. If you have upload.module, the ed_classified module will allow you to override the attachment form description text on classified nodes, supplying administrator-supplied text - this helps users understand what to do in order to create a photo ad.

Coming soon:

  • Installation and configuration
  • Setting new ad durations based on selected taxonomy terms (categories) - as of version 1.5, you can set new ad durations based on the taxonomy term(s) chosen for the new ad.
  • Basic and advanced taxonomy for classified ads
  • Implementing Image/Photo ads - third-party modules
  • Paid ads - using lm_paypal
  • Taking advantage of Views integration
    ads expiring soon, sortable lists, etc.
  • Helping visitors contact advertisers: contact forms, privatemsg module, and contact_default module
    (and http://drupal.org/node/122428, http://drupal.org/node/66648#comment-130975

Location, location, location - using the location.module to provide location-based ads.

You can use the location module to add location-based attributes to ads created using the Classified Ads module

You can see an example of the location module in use on http://gigs.exodusdev.com .

One advantage of this technique is that you can also enable google, yahoo, and other map support available in the location module.

Using location.module with classified ads.
  • Install and configure location.module
  • Enable locative information for ed_classified nodes
    Note: The location module requires that a zip/postal code be entered in order to auto-generate latitude and longitude information, which is required if you want to use mapping functionality - nodes with no zip/postal code entered will require manual editing of latitude/longitude information if you wish to use mapping functions. This implies that if you want ads to show google maps functionality, you should require zip/postal codes be provided for all classified ads. Check location.module access control settings to ensure that users who can create new ads are also permitted to submit latitude/longitude information, as well.

Code Review Module - Coder

Coder is the code review module. The name coder is a double entendre, "coder" being someone who writes code, and "code-r" short for "code review".

User Reference

To be filled in...

Review and Rule Developer References

Reviews

A review is a set of rules designed to accomplish a task. There is a code standards review, a review for upgrading from 4.7.x->5.x, another review for upgrading from 5.x->6.x, there's the beginnings of a security review and a performance review. Each review has an array of rules. The reviews are shown on the UI pages and can be found in the includes directory.

Options

  • #title
  • #link - link to drupal.org page about the review
  • #rules - rule definition (see below)
  • #severity - default severity (minor, normal, critical) for all rules in the review. severity controls the color and icons displayed. this value can be over-riden by individual rules.

Rules

A rule is a single specific pattern to find. Rules can use the following #type:

  • regex - look for a particular pattern
  • grep - looks for a particular string, meant to be faster when regex is not needed
  • grep_invert - look for a particular string that does not exist
  • callback - do anything you want

More about regex rules

Thus, to find all _submit functions you could use

    array(
      '#type' => 'regex',
      '#value' => '_submit\s*\(',
    ),

This example regex looks for _submit followed by optional spaces, and a required left parenthesis. If you wanted to be more specific, since the _submit handler has very specific arguments that are changing, you could look for:

      '#value' => '_submit\s*\(\$form_id,',

Remember, coder is just a helpful tool. It's not going to catch every use-case (people who use different variable names), but a simple rule like this will find all 5.x submit handlers and warn you to upgrade it. If you wanted to be more generic, you could write a rule that looked for two arguments instead of 3, but the regex for that is a little harder.

You can also restrict your regex searches within a function. So, if you wanted to warn about the recent menu changes:

    array(
      '#type' => 'regex',
      '#function' => '_menu$',
      '#value' => '\$items\[\]\s*=|if\s*\(\$may_cache\)',
    ),

This rule looks for $items[] = or if ($maycache).

Quoted strings are replaced with '' in the php source (the default, but see below). Thus if you wanted to make sure that the above had a string array index (such as $items['something'] =, you could have written (BTW, this is a bogus example just to show quoted strings):

    array(
      '#type' => 'regex',
      '#value' => '\$items\[\'\'\]\s*=',
    ),

Rule warnings

Finding code patterns is only half the problem. You also need to write a warning. There are two warning options,

  1. #warning
  2. #warning_callback

So, using the first example above, we should add a warning

      '#value' => '_submit\s*\(\$form_id,',
      '#warning' => t('hook_submit() parameters have changed'),

Notice that this warning uses t for text processing. Since this function takes processing time, and since the rules files are read a lot, there also exists a warning_callback that should be used in most cases. So, the above really should be:

      '#value' => '_submit\s*\(\$form_id,',
      '#warning_callback' => '_coder_6x_fapi_submit_warning',
...
  functions _coder_6x_fapi_submit_warning() {
    return t('!hook_submit() parameters have changed',
      array(
        '!hook_submit' => theme('drupalapi', 'hook_submit'),
      )
    );
  }

Warning Callbacks

Warning callbacks support either a text string or an array. If an array is returned, it should contain:

  • #warning - this is the same as the simple text string (or #warning in the rule)
  • #description - a more detailed description. if supplied, the user can click on "..." and receive more information about this warning

Available source options

Usually, you're just looking for something in the php. But coder supports these #source options:

  • php - this is the