Content Nodes

Nodes are Drupal's next building block, and one of the most important. An important part of planning any Drupal site is looking at your plans and deciding what specific kinds of content (referred to by Drupal as "content types") you'll be working with. In almost every case, each one will be a different kind of node.

All nodes, regardless of the type of content they store, share a handful of basic properties:

• An author (the user on your site who created the content)

Do you want to create a page containing your company's privacy policy? That's a node. Do you want users to be able to post blog entries on the site? Each one is a node. Will users be posting links to interesting stories elsewhere on the Web? Each of those links is stored as—you guessed it—a node.

In addition to nodes' basic, common properties, all nodes can take advantage of certain built-in Drupal features, like flags that indicate whether they're published or unpublished and settings to control how each type of node is displayed. Permissions to create and edit each type of node can also be assigned to different user roles; for example, users with the "blogger" role could create "Blog entry" nodes, but only "administrator" or "editor" users could create "News" nodes.


Title Body Author

Created date

Created date


Choices Results




Comments commentmodule

File attachments_upload module

Figure 1-6. All nodes in the system share a basic set of properties; nodes may define additional, specific fields, and modules can add extra features to nodes as well

Drupal comes preconfigured with two types of nodes: "Page" and "Story." There's nothing special about them—they offer the standard features all nodes share and nothing more. The only differences between those two types of nodes are their default configuration settings. "Page" nodes don't display any information about the author or the date on which they were posted. They're well suited to content like "About Us" and "Terms of Service," where the original author is irrelevant. "Story" nodes do display that information, and are also set to appear on the front page of the site whenever they're posted. The result is a blog-like list of the latest stories on the site.

You can use Drupal's content administration tools to create other "simple" node types yourself. Many administrators create a "news" or "announcement" node type to post official announcements, while other contributors can post story nodes. What happens, though, if you need to store more information than "title" and "body content?" Plug-in modules can add to Drupal's content system new kinds of nodes that offer more features. One example (which comes with Drupal) is the "Poll" module. When users create new "Poll" nodes, they create a list of poll questions rather than the usual "body" content. Poll nodes, when they're displayed to visitors, appear as voting forms and automatically tally the number of votes for each question.

Additionally, other modules can add to nodes' properties such as comments, ratings, file upload fields, and more. From the control panel, you can specify which types of nodes receive these features. Figure 1-6 illustrates this concept.

v Nodes can also store revision information detailing each change that's been made since they were created. If you make a mistake (deleting an ' * y important paragraph of the "About Us" page, for example), this makes it easy to restore a previous version.

The idea that new modules add properties and build on top of the node system means that all content in Drupal is built on the same underlying framework, and therein lies one of Drupal's greatest strengths. Features like searching, rating, and comments all become plug-and-play components for any new type of node you may define, because under the hood, Drupal knows how to interface with their base elements—nodes.

Using plug-in modules to add new types of nodes—or to add additional fields to existing node types—is a common task in Drupal. Throughout the book, we'll be covering a handful of the hundreds of plug-in modules and you'll learn how to build complex content types using these basic tools.

Was this article helpful?

0 0

Post a comment