Creating Drupal Content

This is the fourth in a series of occasional tutorials about Drupal.

All references to Drupal in this article refer to Drupal 6. I’ve been working with Drupal 7 recently and I should be doing some D7 tutorials quite soon.

My first two tutorials dealt with installing Drupal and creating your first theme. This tutorial takes the user a step further. Hopefully after reading this you will be able to add your own content in the Drupal CMS. There was a time, a while ago when you would have had to write quite a chunk of PHP code in the form of a custom module to create your own content in Drupal. This changed and became so much easier with the release of the CCK module which is what we are going to use to create content in this tutorial.

The first thing you will need to do is to download and enable four modules: CCK, FileField, ImageField and Link. This is a relatively easy task but if you aren’t sure how to do it I have created a tutorial here. Once you have these modules installed and enabled you should navigate to Admin – Content Types and hopefully you will see a screen similar to the one below.

Drupal Content Types

You will notice that there are two content types (Page and Story) available by default. I usually leave these two as they are and create a content type of my own. Click the ‘Add a new content type’ link and you are presented with a form like the one below.

Drupal Content Types Form

Though it’s not strictly necessary the convention is for the name and type to be the same but the type should be all lowercase and spaces should be replaced by underscores. We’re going to give our new content type a name of ‘Example Page’ and a type of ‘example_page’. You should enter these values plus a brief description. The three collapsible fieldsets below the Description textarea allow you to customise the behaviour of your new content type. For now let’s just use the defaults. Hit the save button and you should arrive back at the page in the first diagram above with your new Example Page content type appearing at the top of the list.

The next step is to add some extra fields. Click the ‘manage fields’ link and you should arrive at the screen below.

Add Fields to Drupal Content Type

Lets say that the web page that we want to create must contain an image, and a link to a similar page. The first thing we will need to do is to add an image field to our content type. In the ‘New Field’ section enter ‘Main Image’ as the label, ‘main_image’ as the name, select ‘File’ from the first list, select ‘Image’ from the second list and save your work. The screen that you arrive at offers various options but for now, just accept the defaults. Saving the settings on this page should take you back to a list of fields with your new ‘Main Image’ field at the bottom of the list.

Let’s add another field,. Enter ‘Similar Page’, similar_page’, choose ‘Link’ and ‘Link’ in the ‘New Field’ section and save your work. Accept the default settings, save again and you should now have your two new fields at the bottom of the list of fields. Our new content type is now complete! Let’s move along and add some content.

Navigate to Admin – Create Content and you will see a list of available content types with your new Example Page’ at the top of the list. Click on this link and you should see the form below.

Create Drupal Content

Use this form to add a title, some text, and image an a link to the page you are about to create. Save your work and magically, the page that you have just created will appear. You have successfully created your first piece of Drupal content!

In the next tutorial I will show you how to change the appearance of the page you have just created.

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.