The Views module in the Drupal Content Management System
RSS
 View all Hubs
See what's in...

Drupal: Open Source Content Management part 3: Taming the Power of the Database Within Drupal

Part 3 of 4 in the series: Drupal
4
Review of Views module in Drupal
by Profacgillies (4,591 pts )
Published on Oct 10, 2008
A content management system is a database. As such its power lies in the processing of data, in this case the content of the web site. Drupal provides the Views module to query the content of the database and generate bespoke datasets which can provided as pages, blocks or RSS feeds.
165 views
go to: part 1

Introduction

A content management system is a database. As such its power lies in the processing of data, in this case the content of the web site. This involves building queries to select and sort the data that you require. This can be achieved with programming in PHP, but this is a complex task for many users.

The Views Module in Drupal

Drupal provides the Views module to query the content of the database and generate bespoke datasets which can provided as pages, blocks or RSS feeds. The module is not part of the Drupal core but must be downloaded and installed. This is a familiar process because it is similar to the initial installation. Just don’t forget to enable the module in the list of modules! The views module is in essence a query generator which saves the user the task of programming their own queries. Even this can seem relatively complex, but the getting started guide within Drupal provides an approachable guide to the process of creating a bespoke view.

Example Application of the Views Module in Drupal

The website www.alangillies.com has at its heart content which consists of news items stored within Drupal as blog items and opinion pieces stored as stories. The design called for the ability to produce bespoke pages providing separate access to the news items and opinion pieces, and to mirror those pages in RSS feeds.

To create a page of story items such as the opinion pieces at www.alangillies.com, the following steps are required:

1. Log onto the site as the “superuser” with full administrative rights.

2. Select “Administer”

3. From the Administer menu, select “Views” from the “Site Building”

4. Click on Add

5.At the next screen, a name and description are needed, and the type is set to “Node”. This screen is now complete and Next takes the user to the screen where the query itself is constructed.

The default view to be created is a Page, so we can leave this as is and

6. Select the field to display

a. In 3rd column locate the Fields options. Click the + icon to add fields.

b. Scroll down to Defaults: Add fields. In the Groups drop-down menu select 'Node', then check the following field: Node: Node Title.

c. Then click Add.

d. The system will then offer you the chance to change the options associated with this field. For the Title field: Delete the 'Title' label. Select Link this field to its node.

e. Click Update.

7. Filtering to story nodes only

a. Click the + icon next to Filters.

b. In the Groups drop-down menu select 'Node', then check the Node: Published and Node: Type filters, and click Add.

c. Select the Published checkbox. Click Update

d. Select Is one of and check Story in the Node Type field. Click Update.

8. Sorting to show most recent first

a. Scroll up to Sort criteria and click the + icon.

b. In the Groups drop-down menu below, select 'Node', then check Node: Post date, and click Add. Alternatively, you may instead check Node: Last comment time, or Node: Updated/commented date, or Node: Updated date.

c. Select Descending Sort order. Click Update.

9. Refining the basic settings

In the 1st column under Basic settings change the following options:

a. Items to Display setting, click on 10 and change the “10” to “6”.

b. Click Update

c. At the Style setting, click on Unformatted and change to List.

d. Click Update.

10. Creating the bespoke page

a. In the dropdown on the left, ensure that Page is selected, and click Add Display.

b. Under Page settings, click the None link next to the Path setting.

c. Give the page a path so it can be managed with Drupal.

d. Click the None link next to the Menu setting, and attach the new page to the menu of your choice

11. Saving the view

a. Click Save to save your work.

Conclusions

The query function is at the heart of any database

. The Views module provides an easier way to write queries than PHP programming, and the getting started guide does a good job of guiding the inexperienced user

Drupal

Drupal is a powerful open source content management system. This series of articles reviews its usability for an intermediate user with no prior knowledge of PHP and MySQL developing on a Vista running PC and a third party server.

Bright Hub - Science & Technology Articles, Buyer's Guides, How-To Tips and Software Reviews
About Bright Hub | Contact Us | Terms of Use | Privacy Policy | Copyright Policy | ©2008 Bright Hub Inc. All rights reserved. Page copy protected against web site content infringement by Copyscape