Drupal: Content authoring and taxonomies

Dr Andres Baravalle

Drupal: Content authoring and taxonomies

  • Content authoring
  • Taxonomies
  • Content authoring (reprise)

Before we start

As in the past weeks, you will engage in a number of activities. The activities that you will have to work on may not fit well within the web site that you are planning to develop.

Please work on all the activities, as they are meant to familiarise you with Drupal features, but keep in mind that you might have to rever some of the changes that we will be working on today after the class.

If at any point you become stuck with your development, you can always drop all your tables ( = content) and restart the web site. While a bit drastic, it might be required when you are walking your first steps with Drupal.

As your development progresses, you should be making regular backups of your web site (both files and database). Use WinSCP to backup the files and phpMyAdmin to backup the databases (or select any suitable Drupal modules).

Before we start (2)

Please remember that altough there are a number of on-line sources to learn how to use Drupal, it will be much easier if you start from one or more of the following books:

  • Mercer, D. (2010) Drupal 7
  • Tomlinson, T. (2010) Beginning Drupal 7
  • Tomlinson, T. and VanDyk, J. K. (2010) Pro Drupal 7 development
  • Madel, K. (2012) Drupal 7 Development by Example Beginner's Guide
  • Tal, L. (2013) Drupal 7 Media.

They are all available in our library.

You should use on-line resurces and these slides to comlement your study - not as a sole source of knowledge.

Content authoring

Adding content

Last week you have seen how to create basic content with Drupal (e.g. forum topics); today we'll start by looking at how to create Drupal pages and articles.

A Drupal site can contain many types of content (e.g. pages, news, polls, blog posts). In Drupal, each item of content is called a node, and each node is based on a single content type.

The most basic content types are the article and the basic page:

  • The Article content type is generally used for information that is updated more frequently and often cross-referenced and categorized (such as news items or resources).
  • The Basic page content type is generally used for static content.

You can customise content types through the structure menu in your Drupal installation: /?q=admin/structure/types

Customising content types

You can customise content types by adding extra fields.

The most common fields are:

  • Title: to identify nodes (mandatory)
  • Boolean, Integer, Decimal and Float: to add numbers
  • File, Image: to attach files and images
  • List: to present a list of options
  • Long text and summary, Long text, text: to add text
  • Term reference: to reference taxonomy terms (more on this later)

Article vs Page

The Article content type includes the fields Term reference, Long text and summary and Image.

The Basic page content type includes the field Long text and summary.

Activity #1

Let's review what we have just seen by creating a new Drupal Article and adding a black cat image to it. You can get the image from wikipedia.

What if you want to add more than one image?

Activity #2

Update the Basic page content type to include an image field; start from /?q=admin/structure/types.

Create a new Drupal page and add a black cat image to it.

You may have to revert this change later on for your project(s).

Are you stuck? Refer to the documentation.

Text formats

Drupal supports 3 default text formats:

  • Filtered HTML
  • Full HTML
  • Plain text

They can be customised in /q=admin/config/content/formats

Text formats (2)

Under normal circumstances, you would want most of your users to post only content in Filtered HTML, but you may want to allow the developers to use Full HTML.

This can be done (for example) by allowing authenticated users to create Articles, but not Pages, and allowing Full HTML only for pages.

Advanced text formats

If you enable the PHP filter module, you can allow users with some roles to include PHP in their nodes.

What are the advantages and disadvantages of this?

What precautions should you take?

Taxonomies

Taxonomy

Taxonomy is the practice and science of classification. 

In our context, taxonomy refers to a classification of content inside Drupal.

You can customise your taxonomy through the structure menu in your Drupal installation: /?q=admin/structure/taxonomy

Taxonomy: core therminology

  • Term: a term used to describe content
  • Vocabulary: a grouping of related items
  • Tagging: associating content with terms

Taxonomy example

On my personal web site I use a number of vocabularies to tag my content:

  • Places
  • Research and development
  • Teaching
  • Images
  • Other

Vocabulary example: Places

My places vocabulary includes the places that I mention in my blog posts or pages. Here is a shortened version of it:

  • argentina
    • la jovita
    • patagonia
    • rosario
    • valdes
  • belgium
  • canada
  • croatia

Activity #3

Create (on paper) a suitable taxonomy (at least 12 terms) for a domain of your choice, to be used to tag your Article nodes.

Discuss it with the classmates beside you and then:

  1. Implement it on your Drupal site (as vocabulary)
  2. Update the Articles node to use the new vocabulary by default:
    1. In the Article node, you must display the terms as links
    2. Use a select widget

Hierarchies

You can build complex, hierarchical taxonomies with Drupal - and update them as you need.

Content authoring (reprise)

Images

As we have seen earlier on, any content type can be customised to include images. The next slides will show you how to create more advanced content.

WYSIWYG

The WYSIWYG module can be used to integrate a WYSIWYG editor into your web site.

Installing modules

In the past weeks we have seen how Drupal can be extended by installing new modules. We are now going to see how to do it.

There are different ways to install modules - the symplest is to:

  1. If you do not have it yet, you need to create a folder named sites/default/modules under your local Drupal installation. All your modules will reside there.
  2. Download the module from the Drupal web site (use the zip archive - not the .tar.gz)
  3. Extract the module. Make sure that the folder includes a file named MODULENAME.module; if not, you may need to drill into the folder structure of the module
  4. Move the module folder (the one directly including the MODULENAME.module file) into your modules folder
  5. In the modules tab, enable the module

Installing modules: troubleshooting

If there are any errors, read the error description and try to understand what it means. Use search engines if you find yourself lost.

You you cannot see any errors, consult the Drupal log.

Activity #4

Following the instructions in the previous slides, download, install and the WYSIWIG module. This require some post-installation configuration - follow the steps on screen after enabling the module.

Download an install TinyMCE (use version 3.5.x, not any version in the 4.x branch) as the default editor for the WYSIWIG module.

Review the Content authoring page (/?q=admin/config/content) and customise your Wysiwyg profiles, adding a suitable set of buttons and plugins for the different text formats.

Activity #5

If you do not have it yet, you need to create a folder named sites/default/files/images. This is where you will save all your images; upload a few images to the folder using WinSCP.

Try the WYSIWIG module by creating a new Basic page with at least 2 images.

This work

This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License

Creative Commons License