| Drupal

It's fairly common to replace the title field in Drupal.

There are many possible reasons to replace the title, but most of them come down to this ... the title field is not very flexible.

To take just one example, imagine that you're adding a directory of your staff members to your site. Presumably, you'd like the person's name to be the title of each page. However, because the title field only consists of a text field with 255 characters, you can't have close control over what people enter. The solution is to replace the default title with specific "First Name" and "Last Name" fields.

So, here's how to automatically generate titles in Drupal 7.

media_1352773828770.png

Step 2: Set Up Each Content Type

  • Go to Structure > Content types
  • Look for the automatic title generation area as in the image below
  • You'll be able to use tokens to automatically replace the title
media_1352774012751.png
  • In the example below, we're completely hiding the title field. If we choose the bottom radio button, the title field would be available to users and our tokens would only work if the title field isn't used.
  • In the image below, we're automatically replacing the title with the First name and Last name fields.
media_1352774943444.png

Step 3: Create the Content

  • Click Add content and create an example of your content type
  • Notice that the title field is completely missing
media_1352775119615.png
  • Save the content and your title will be automatically generated:
media_1352775267754.png

About the author

Steve is the founder of OSTraining. Originally from the UK, he now lives in Sarasota in the USA. Steve's work straddles the line between teaching and web development.