• warning: Parameter 1 to theme_link_node_thumbnail() expected to be a reference, value given in /home/diysite/public_html/includes/theme.inc on line 617.
  • warning: Parameter 1 to theme_link_node_thumbnail() expected to be a reference, value given in /home/diysite/public_html/includes/theme.inc on line 617.
  • warning: Parameter 1 to theme_link_node_thumbnail() expected to be a reference, value given in /home/diysite/public_html/includes/theme.inc on line 617.

Organising your content

If you have a lot of content on your site it is critical for it to be well organised so your visitors can find what they are looking for quickly and easily.

Drupal has a powerful system called taxonomy to help you organise your content.  Taxonomy is another name for categories and you can have more than one type of category (vocabularies) that apply to your content.  For example a clothing product could be categorised under size and also male or female.  It is easy for you to set up these categories and then apply them to your content.

Let's create our first category 'Size'.  For our purposes we are going to

  1. Go to: Content management > Taxonomy > Add vocabulary
  2. Enter the name of your category e.g. Size
  3. Select the content types you wish to use this category with
  4. Change weight to -1 so size is always displayed first and save (by default there is no distinction between vocabularies so all terms are ordered alphabetically)
  5. Click add terms
  6. Enter: Small and save
  7. Do the same for medium and large
  8. Now add a new vocabulary e.g. Gender and add the terms Male and Female

Now when you create a new page of the content type you selected you will be able to categorise them. 

Later in this tutorial I will be showing you how to filter content and choose what you display to your users.  Now would be a good time to be able to handle images.

Setting up imagecache

The imagecache module will automatically resize images and then save them for the next time they are requested.  With HTML it is possible to display an original file in any dimensions.  This means that a small thumbnail could actually have a large filesize and take a long time to load.  Imagecache will take that large image and automatically resize it down to a small filesize with the correct dimensions.

  1. Download ‎ImageCache‎ and enable imagecache and imagecache_ui.
  2. Go to: Site building > ImagaCache
  3. Click 'Add new preset'
  4. Enter a name e.g. thumbnail
  5. Click on 'Add Scale And Crop' (I almost always use this action because it allows all images to conform to the same dimensions)
  6. Enter a width of 160x100 (Which will give us a golden ratio)

You can now use this image size throughout your site.

CCK Image Field

There's a module for ‎Content Construction Kit (CCK)‎ called ‎ImageField‎ which allows images to be uploaded to a field.  This field can hold one or even multiple images and then display them in a pre-defined format, see:

  1. Download and enable ‎ImageField‎ and ‎FileField
  2. Go to: Content types > Edit Page > Manage fields (Or another content type you wish to an an image field to)
  3. Enter a Label and Field name for your image
  4. Select the 'File' type and the 'Image' form element
  5. Under 'Global settings' you can select the number of images to allow
  6. Click 'Save field settings'

If you have set up you can choose how the image should appear:

  1. Click on the 'Display fields' tab
  2. Select the imagecache preset for your Teaser and or Full node

Note: With ‎Lightbox2‎ installed you will have display options with zoom functionality.

Creating and filtering content

Let's create a few pages selecting different terms and inserting an image. When you save a page you will see the terms listed as links at the bottom.  If you click on one of these it will show you all content that has the same category.  This in itself isn't that useful so we'll now see how you can allow your users to filter your content using multiple categories.

To filter your content we will be using the module.  It's a very powerful module with many options.  I will be introducing you to a small portion of it.

If you haven't already, download ‎Views‎ and enable Views and Views UI.

Views in its most basic form allows you to create a list of content depending on certain terms. We are going to allow your users to filter your content themselves so they can find what they are after.

First of all we are going to create a view and limit the content to a specific type.

  1. Go to: Site building > Views > Add
  2. Fill out 'View name' e.g. clothes or whatevever you want to call your list and click 'Next'.

Now you will see quite a complex page. The bit we're interested is on the right: 'Filters'.

  1. Click on the + icon
  2. Change 'Groups' to 'Node'
  3. Scroll down, check 'Node: Type' and click 'Add'
  4. Check 'Page' and click 'Update'

At this point you may get an error. This is because it is set up to display fields but we haven't selected any.  To avoid this error lets set the view to display nodes.

  1. Under 'Basic settings' > 'Row style' click Fields
  2. Select 'Node' and click 'Update'
  3. Change build mode to 'Full node' and click 'Update'

At the bottom you should see several 'page' nodes that you created earlier.

Now we are going to do the work to allow users to filter themselves.

  1. Under filters click '+'
  2. Change 'Groups' to 'Taxonomy'
  3. Check 'Taxonomy: Term' and click 'Add'
  4. Select the 'Gender' Vocabulary, change 'Selection type' to 'Dropdown' and click 'Update'
  5. Click 'Expose'
  6. Change 'Label' to the vocabulary you entered e.g. 'Gender' and then click 'Update'

Repeat for the other vocabulary and then save the view.

Now we're going to create a page to display this information:

  1. On the left check the dropdown says 'Page' and click 'Add display'
  2. In the bottom left under 'Page settings' click on Path > 'None'
  3. Enter a path such as 'clothes' and save the view.

Now at the top right of the view there is a 'View "Page"' link that will take you to your new page.

This page simply shows several full nodes.  Earlier we changed the row style to node. Usually we want to display a limited amount of information and we can do this using fields.

  1. Change 'Row style: Node' to Fields and click 'Update default display' and then 'Update default display' again.
  2. Click '+' under fields
  3. Change 'Groups' to node
  4. Check 'Node: Title' and click 'Add'
  5. Check 'Link this field to its node' and click 'Update default display'

You'll now see just the title in your preview but we probably don't want the title label

  1. Click 'Node: Title' under Fields
  2. Delete 'Title' from 'Label' and click 'Update default display'
  3. ##############
  4. Change 'Groups' to content
  5. Select 'Content: Image (field_image)' and click '

More about Views

Now that you've created a view and understand what they do I'll explain the rest of the features:

Basic settings

  • Name: This changes the name of the view display so you can easily identify it
  • Title: This changes the title of the view as it is diplayed to users
  • Style: This changes the way the entire view appears. Table style is particularly useful because you can sort by clicking on the column headings
  • Row style: This changes how each individual node is displayed
  • Use AJAX: AJAX is a dynamic technique used to refresh part of a page.  This means that if you sort a table or change page, only the view will be refreshed, not the entire page.
  • Use pager: When you have many items you don't want to have them all displayed at once.  This will allow your users to page through results.
  • Items to display: Change the number of items displayed on each page.
  • Distinct: Certain view options will cause a node to appear more than once.  This will help to stop that.
  • Access: You can use this to limit access to the view to certain people.
  • Caching: Generating views requires processing.  You can minimise this processing by changing caching options.
  • Exposed form in block: We exposed filters for taxonomy that appeared at the top of the page.  We can change where it appears by selecting this option.  You must enable the block yourself ########
  • Header: Allows you to insert your own content above the view list.
  • Footer: Allows you to insert your own content below the view list.
  • Empty text: If the view options results in no items you can choose what text to display here.
  • Theme: This is a pretty advanced feature.  It basically allows you to use your own HTML templates to display a view.  #######