RelatedContent

RelatedContent is a Drupal module that allows privileged users to assemble teasers at the end of a node. The teasers are selected from a list of nodes. The list is provided by a view from the Views module. The number of nodes and the view to get them from are configurable for each node type.

Background

It is very common for websites to plug for material on the site by presenting abstracts, which in Drupal idiom is called "teasers". There are many great solutions for doing this in Drupal: taxonomy, views and queues, to mention a few. In spite of these possibilities, there is still need for an alternative way of compiling teasers to be shown. In this section, a quick review of some possibilities are given, and the need for an alternative is explained in the context of an actual use case.

Special pages with teasers are provided out of the box for nodes that are categorized by the core Taxonomy module. If your needs are more elaborative, you can compile a such page (or block) yourself with the wonderful Views module. In both cases, you cannot directly select which teasers to show. Instead you are reduced to setup conditions for the viewed teasers to meet.

To directly select teasers to show, you can resort to the Node Queue module. With the Node Queue module, you can create a "queue", which is a named set of references to nodes. You add references by visiting the nodes one by one or en masse by using the Node Queue Builder module. Once created, you can embed a PHP snippet into a node or a block to view teasers of the nodes referenced by a particular queue.

Although powerful, the Node Queue approach is not always suitable. To understand why, consider the cause for writing the RelatedContent module in the first place:

The Simplenews module can be used to provide newsletters for visitors to subscribe to. The module provides a particular content type called "Newsletter issue". When editing a newsletter issue, the editor has a single text-area for the content. It is suitable for self-contained newsletters. However, it cannot easily be used to accomplish newsletters made up of an introductory text followed by teasers to articles already published on the website. RelatedContent was developed to extend Simplenews (and other content types) with this possibility.

So why is Node Queue less appropriate for this particular purpose? There are at least two reasons:

First, it would be necessary to write PHP code in order to pull out teasers from the nodes referenced by a queue. Probably the editor of a newsletter issue is not a programmer, and hence not comfortable with (or versed in) writing PHP code. It is also a security risk since the editor must have a role with the privilege to use the PHP code input format.

Second, and a little more subtle, but nevertheless a problem, is the fact that changes in a queue is propagated to wherever the queue is used. For a newsletter to not change on the web after it has been published, the queue must not be altered. The implication is that it is necessary to setup a unique queue for each issue, which is not feasible in the long run.

Both these problems are overcome by using the RelatedContent module.

Requirements

To install RelatedContent you need:

Installation

Install RelatedContent as follows:

  1. Download, install and configure the Views module, following the instructions for that module.

  2. Download the archive file with the latest stable version from RelatedContent project page

  3. Unpack the downloaded archive into your Drupal's modules directory.

  4. Verify that the modules directory contains a relatedcontent directory with relatedcontent.module and other files.

  5. Go to admin/build/modules and enable the module.

Configuration

RelatedContent is configured for each content type individually. By default, it is turned off. To enable RelatedContent for a particular content type, do as follows:

  1. If not already existing, go to admin/build/views and add at least one view that filter nodes to be used by the RelatedContent.

  2. Go to admin/content/types/<type>, where <type> is the name of the content type, e.g. page or simplenews, and locate the RelatedContent settings.

  3. In the pull-down menu named RelatedContent view, select the view that that filter nodes to be used by the RelatedContent. Leave empty to disable RelatedContent.

  4. In the pull-down menu named Max number of nodes, select the maximum number of nodes to be available for the RelatedContent.

Usage

When creating or editing a node of a content type with RelatedContent enabled, select nodes to be shown as follows:

  1. Locate and open the collapsible section called Related content.

  2. Check the checkboxes to the left of the nodes whose teasers are going to be shown.

Theming

The RelatedContent module provides following themable functions:

Plans for the future

The RelatedContent module will be further developed. Following issues are known and will be dealt with in future versions of the module:

License

RelatedContent. Copyright © Thomas Barregren.

RelatedContent is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

RelatedContent is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.