My BlogAbout MePortfolioTemplatesArticlesWeb StoreMessage Board (Forums)Guestbook

Drupal for Solid Lifeforms

Submitted by Jakob on 4 September, 2006 - 20:32.My Blog | Drupal | Human-Computer Interaction | Web Design | XHTML

A beginners FAQ and guide to one of the most formidable content management systems on planet Earth

Some of you who frequent my site may have noticed that I work a lot with Drupal and now offer Drupal-related services such as customization and design. If youre curious about what Drupal is and what it can do for you, how you can build a better site - a site thats easier to maintain using a state of the art CMS, this guide is for you.

Whom is this guide written for?

This is written for everyone with an interest in CMSes and Drupal and who has a basic understanding of web publishing, design and development. The goal of this guide is to explain the basic concepts and features of Drupal and show examples of how they can be used on a real Drupal powered website in order to inspire. My goal is simply to bridge the gap between theory and practice and turn a rather fearsome leap over the abyss of the unknown into a walk across the bridge that is this guide, the bridge you are now taking your first steps on.

What is Drupal?

Drupal is framework and a so called content management system, or CMS for short. Content management systems allow you to easily structure, create, automate, build, present and maintain large collections of content. Most CMSs are designed to power websites and relieve webmasters of the burden of repetitive tasks, allowing them to focus on providing fresh interesting content and building a great website.

Why should I choose Drupal?

There are many open source CMS solutions available, some of the most popular are Joomla, phpNuke and Drupal. While choosing a CMS is much a matter of taste and what floats your boat, there are technical aspects. Of all the free open source content management systems available today very few offer such a flexible, open and developer-friendly architecture as Drupal and such complete documentation, factors that make Drupal the perfect choice if you need a solution that allows growth. When your site grows, Drupal will grow with it since you can modify so many aspects of it and add new features as necessary.

Is Drupal hard to learn?

As with everything theres a threshold, some say Drupals threshold is higher than that of other CMSs but I dont agree. This guide is an attempt to lower that threshold further by explaining some of the underlying concepts of Drupal. Since in order to use Drupal effectively you need to understand how its different components work together, how you can build your site using these components, and take advantage of some of the brilliant features that makes Drupal truly shine.

The underlying concepts of content management in Drupal

Drupal offers several tools and concepts to handle content effectively. I will list some of these defining features here and explain how they apply to running a regular website.

A website understood in terms of content management

When you think about a site, in fact imagine a website now. What comes to mind first? The layout perhaps? Well it depends on whether youre a visual thinker or not but most people are aware of layout, or rather what kind of content they want there, those ideas be sharp and well-defined or fuzzy. If you are an experienced web developer you will also consider how you can achieve it, you think in terms of CSS, XHTML and various other server and client-side technologies. I will address all of these aspects in this guide.

But for now I will assume a more holistic view of website building here as this guide is meant to be of use to people at all levels. So let us, for the sake of simplicity imagine our site, its front page and its general layout.

Because of the underlying metaphors of the web, websites are considered having pages. Each of these pages cover a certain topic, contains an article or some piece of information or content. Some pages list dynamic content, sport results listing or posts in a forum topic.

Similarly, a websites front page lists new pages, new articles, new forum posts or may even aggregate information from other sites. Now looking at Drupal without a clue how it works, it may be hard to imagine how this all can be done. I will attempt to answer that question.

Presenting the node (content)

In essence, and according to the Drupal view of things, a website is merely a collection of content objects, and the presentation of these is controlled by logic (programming) and design (XHTML and CSS). In Drupal, all content is stored in nodes and a node is a content object. Just like there are different kinds of content, say a news item for the sites front page and a regular sub page, there are different types of nodes.

Nodes are very versatile and can be accessed in many different ways. A node and its content can be displayed all alone, like a page on a site, or it can be listed along with all other nodes that are either of the same type or share other properties. Unlike in some CMSes, such as TYPO3, nodes do not exist in any form of hierarchy, such features are provided by the Taxonomy module which I will explain later. As you will see, the node abstraction allows us to manage content very effectively.

The easiest way to build your website is to create all content as nodes of the type Page. Like I mentioned earlier, there are different types of nodes, all intended to be used for different kinds of content. The Story node type is intended to be used for news, content that has a lifespan and is recent. The Page node type is intended for static information such as the pages on your site that hold the sites information. There are several other node types, and you can even create new nodes types or download modules that add additional nodes types to fit the needs of your site, however explaining this is beyond the scope of this guide.

Nodes can have several revisions, or versions. When you save your node you can check the option to have a new revision made, by doing so the old version will not be overwritten but stored allowing you to revert to it should you change your mind about the changes you just made.

By default, a Drupal sites front page will list all the nodes set as as promote to front page ordered chronologically, most recent coming first. By selectively only promoting Stories to the front page, you can easily create a flow of news items directly accessible to those coming to your site. However should you not want that you can always change the node type's default settings in administer -> settings -> content types.

All nodes are identified by their NID, which is short of Node ID. The NID is used to identify the node in the database where it is stored. You can also access all nodes on your site by typing in the following after your sites address: node/NID where NID is the NID of the node you want to access. Doing this will display the node in your browser.

Using NID as reference, by programming or by advanced site customization nodes can also be included in other nodes, or in blocks which are the second concept I am going to present.

Blocks for displaying information (presentation)

When you build a page layout you usually intend certain areas of the page to contain certain content. These areas can contain text, images, navigation or different kinds of sidebars. When it comes to the elements that make up the different parts of a web page layout, Drupal distinguishes between content and blocks. Content is the body of a node and could consist of text and/or images. is displayed in a designated area on a page. Blocks are containers for things such as navigations bars, links and log in forms, that are shared by many (or all) pages of a Drupal site.

A block is a box (with or without visible border) which you can move around by assigning it to the different regions. Blocks are more free compared to content since they can be moved around. Where you can place blocks depends on the regions available in the theme you are using. Regions are areas and containers that you place blocks inside. The block system also allows you to change what blocks to display where depending on what section of a site you are in. In a three column layout, the left and right columns along with header and footer are the areas with regions, with the center column used for content. The default Bluemarine theme (in Drupal 5 the default theme is called Garland) allows content to be placed in at least these four different regions.

Typical uses of blocks is to display navigation menus that are the same across all pages of a site, display who is logged in or a log in form for members. In essence; blocks are good for things that are shared across the pages of a Drupal site, with the added advantage that you can decide exactly om what pages a certain block should be visible.

You can also create your own blocks with your own content. In this way, a block can work as a regular node, except it lacks some features such as limiting access and supporting revisions or the ability to easily edit it by clicking its edit tab.

Most themes have one primary column for the content, that is the container for the content of the node being displayed, and side containers for blocks as this is a very common and popular website layout. This however doesnt mean this is the way a Drupal site has to be designed. My site which you are looking at right now uses a less conventional layout. For other examples, see the links below.

A lot of people wonder how to create front pages and web site pages with more complex layout than the one I just described. The layouts may consist of several containers of content and several navigation bars and links, banners et c, in essence all the glamour and splendor we have come to expect from modern websites. Blocks can help you achieve this by combining them with your own custom theme and additional modules such as Views and Panels, which allow you to present information in an unlimited number of ways. By building your layout and creating a region for each area you want to place content in, you can very effectively assign content to specific areas and build complex layouts. I mention this as a side note, since explaining how it's done is beyond the scope and purpose of this guide.

For some inspiring examples of Drupal powered sites with alternative layouts, please see:

http://www.theonion.com
http://www.terminus1525.ca
http://www.mtv.co.uk
http://www.flixya.com
http://www.webbredaktoren.se

Taxonomy for classifying and ordering content (structure)

One of the features that set Drupal apart from every other CMS available today is something called Taxonomy, sometimes referred to as categories. I prefer the former term as it better captures how powerful this concept is.

Taxonomy is a powerful way to categorize and structure the content of a site and to specify how different categories are semantically related to each other; that is how their meaning is related. Using Taxonomy you can build trees (known as vocabularies) of topics (known as terms) to define the conceptual and semantic structure of your site. The tree can illustrate the purpose, meaning and relationship of one node to another. This may sound like mumbo jumbo to most people new to Drupal but once you get the hang of it, youll be hooked.

In order to better illustrate the advantages of Taxonomy, Ill get real and make an example. Imagine you a run a site where people have blogs. Support for blogs is a core component of Drupal and lets every user at your site run his or her own blog. Every blog entry is stored as a node. In order to better structure your site you have also set up a vocabulary called topics, it is a flat vocabulary meaning it doesnt form a tree so it doesnt have any hierarchy, it's a list of terms. It is also set up to support free tagging, meaning your users can add their own terms to the tree ad hoc; that is add them as they need them. You have also specified that blogs must at least have one term in this taxonomy; forcing people to assign terms to their blog posts as they make them.

A user on your site, Anna, just created a great new recipe for cinnamon cookies and wants to share it with her friends so she makes a new blog post about her cookie recipe and how she came up with it. She uses the tags/terms cookie and recipe to describe her blog post and clicks Submit. Her blog post is now available for other people to read.

Sean, who loves cookies and sometimes bakes, and happens to have a day off work, decides he wants to bake cookies. Sean is a regular member on your site and knows that some of the other members are good at coming up with new recipes. Eager to try something new, Sean browses your site. Now this is a situation you have anticipated, therefore youve made it possible to search content by taxonomy terms; that is search nodes tagged with certain terms. Sean searches for the terms cookie recipe and several hits pop up, including the one Anna just added. By clicking either term, Sean can also find more blog posts about cookie or recipe. Still, we've only brushed the surface of what you can do using Taxonomy.

It turns out Sean loves Annas cookie recipe and returns to post a comment on her blog post thanking her for sharing her recipe on the site.

Comments (user interaction)

What Sean just did was to interact with another member at your site. He posted a comment on her blog post. Every node type, be it Pages, Stories or Blog Posts, supports comment posting. That means that you can decide if you want to allow registered users to guests (anonymous) users to actively contribute to your site and spawn new discussions on the topics covered.

Comments are associated with a node, they are not nodes as such however some people in the Drupal community have the view its the most logical approach. Regardless, comments are an essential part of any site that wants to encourage user contribution and interaction.

Modules (unlimited extension)

All of the features Ive listed above are made possible through Drupals module system. A module adds new features, or enhances existing ones. Drupal ships with a number of core modules; the blog module is one of those. There are also hundreds of user contributed modules that add features to your site and which can be download from the Drupal website. Installing a module is a snap, download, uncompress, upload and install. Installing and deactivating of modules is done using Drupals module administration area.

Unlike some forum and CMS system, modules do not require you to edit code manually, in fact no changes are done to the Drupal files, instead Drupal uses a different approach which allows you to enable and disable modules at any time. In fact, Drupal has a feature called Throttle that allows you to disable certain modules when your site is under heavy load and has many simultaneous visitors in order to keep it working.

Path (page names that make sense)

Another defining feature of Drupal is the path module, which is also included in core. The path module allows you to make your site's URLs make a lot more sense than they otherwise would. The URL is the address your visitors will see in their browsers address bar when visiting your site. It consists of a domain name (for example www.yoursite.com) and a so called path to the page or section of the site that is being viewed. A lot of websites today have pages with paths that make absolutely no sense, for example:

http://www.cnn.com/2006/HEALTH/conditions/08/24/hpv.talk.ap/index.html

Yet this is one of those that make relatively much sense since we by looking at it can deduce that the page in question concerns health. With the path module you can assign user-friendly, easy-to-remember paths to your pages. See this example with the default path for the Page node with your About Me page and its corresponding path thats easier to remember and makes more sense:

http://www.yoursite.com/node/18 -> http://www.yoursite.com/aboutme

Human-readable paths arent just easier to remember, they look more professional as they hint at the fact that your site does indeed use a CMS and doesnt rely on static .html-documents.

In the next part I will explain how you build a regular web site with Drupal, how you create your own menu, customize the header and footer and fill your site with content using nodes such as Pages and Stories.
 


I am posting this guide in parts as I write them, it will eventually be compiled as a complete guide and edited for consistency to be published here.



Trackback URL for this post:

http://www.jakob-persson.com/trackback/512

Reply



The content of this field is kept private and will not be shown publicly.


*

  • Web and e-mail addresses are automatically converted into links.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
Verify comment authorship
Captcha Image: you will need to recognize the text in it.
*
Please type in the letters/numbers that are shown in the image above.