Skip to content

Drupal - Announcements

Drupal - Creating an ‘Announcements’ Feature

Section titled “Drupal - Creating an ‘Announcements’ Feature”

Often, websites need a way to display important news, updates, or announcements. Drupal’s flexibility allows you to easily create a dedicated ‘Announcements’ feature using its content type system. This involves creating a new content type specifically for announcements.

By creating a distinct ‘Announcement’ content type, you can manage these items separately, control their display, and even create dedicated views or feeds for them.

Steps to Create an ‘Announcement’ Content Type

Section titled “Steps to Create an ‘Announcement’ Content Type”

Step 1: Navigate to Content Types

In the Drupal administration menu, go to ‘Structure’ > ‘Content types’.

Description: This page (/admin/structure/types) lists all existing content types like ‘Article’ and ‘Basic Page’.

Step 2: Add a New Content Type

Click the ’+ Add content type’ button.

Description: This will take you to a form to define your new content type.

Step 3: Define the ‘Announcement’ Content Type

Fill in the basic information for your new content type:

  • Name: Enter Announcement. This is the human-readable name.
  • Machine name: Drupal will suggest announcement (or similar). This is used internally and in code. It’s good practice to keep it simple and descriptive.
  • Description (optional): Add a brief description, e.g., ‘Use for site-wide news, updates, or important notifications.’

Under ‘Submission form settings’:

  • Title field label: You can keep it as ‘Title’ or change it to something like ‘Announcement Headline’.

Review other settings like ‘Publishing options’ (e.g., whether announcements should be published by default) and ‘Display settings’ (e.g., whether to display author and date information). For announcements, you might want to uncheck ‘Display author and date information’ if it’s not relevant.

Click ‘Save and manage fields’ or ‘Save content type’.

Description: You’ve now created the basic shell for your ‘Announcement’ content type.

By default, your new ‘Announcement’ content type will have a ‘Title’ and a ‘Body’ field. You might want to add more specific fields.

Step 4: Add or Modify Fields (Optional)

If you clicked ‘Save and manage fields’, you are already on the ‘Manage fields’ tab for your ‘Announcement’ content type (otherwise, go to ‘Structure’ > ‘Content types’, click ‘Manage fields’ for ‘Announcement’).

Common fields to add for announcements:

  • Announcement Date (Date field): If the announcement pertains to a specific date different from its creation date.
  • Expiry Date (Date field): To automatically hide or archive announcements after a certain date (requires custom logic or a contributed module like Scheduler).
  • Announcement Type (Taxonomy Term Reference field): To categorize announcements (e.g., ‘Urgent’, ‘General Info’, ‘Event’). You’d first need to create a ‘Taxonomy Vocabulary’ for these terms.
  • Link (Link field): If the announcement primarily points to another page or external resource.

To add a field, click ’+ Add field’, choose the field type, label it, and configure its settings.

Example: We keep the default ‘Title’ and ‘Body’ for simplicity in this basic tutorial.

Step 5: Configure How Announcements are Displayed

Go to the ‘Manage display’ tab for your ‘Announcement’ content type. Here you can control the order and format of fields when an announcement is viewed.

  • Drag and drop fields to reorder them.
  • Change the ‘Label’ display (e.g., Inline, Above, Hidden).
  • Change the ‘Format’ for each field (e.g., how a date is displayed, or if the body text should be trimmed).

Click ‘Save’ after making display changes.

Now that your ‘Announcement’ content type is set up:

Step 6: Add a New Announcement

Go to ‘Content’ > ’+ Add content’ > ‘Announcement’.

Fill in the ‘Title’ (e.g., ‘Scheduled Maintenance on Sunday’) and ‘Body’ (details of the announcement).

Click ‘Save’.

You can display announcements in various ways:

  • Individually: Each announcement will have its own page.
  • Listing Page (View): Create a View (Structure > Views > Add view) to display a list of announcements, perhaps on the homepage or a dedicated ‘Announcements’ page. You can sort them by date, filter by type, etc.
  • Block (View): Create a View block to display a few recent announcements in a sidebar or header.
  • Site Alert Modules: For very prominent, site-wide temporary announcements (like a banner), consider contributed modules such as ‘Site Alert’ or ‘Simple Message Banner’. These might be simpler than a full content type if the announcements are ephemeral and need high visibility.

Practical Application: A company website creates an ‘Announcement’ content type to inform users about new product releases and upcoming webinars. They create a View page at /announcements to list all announcements and a View block on the homepage showing the three most recent ones.

Additional Resources: