How To Quickly Change Your Drupal Homepage
Coming from a newspaper and publishing background, I've routinely been asked to change a homepage at a moment's notice to respond to a breaking news story or event. This can be tricky with many websites since so much has been templated into a CMS system. Before sites were created using a content management system, developers could quickly create a copy of the homepage, edit some HTML and create an entirely new look quickly.
This method can still be done as we'll get into later, but how should this custom page look? What are the elements you want to use?
Prior to a breaking event happening a plan should be created to decide what kind of result would be wanted. Nobody knows what the breaking event will be but scenarios can be brainstormed amongst your team. Don't limit your ideas during this phase. You might be planning for breaking events, but you never know when these templates could be used in other situations.
Creating templates for various scenarios keeps you prepared and allows your developers to easily switch-out homepage content.
Methods of changing homepage layouts
In Drupal, a developer can:
- change layouts writing custom HTML
- quickly get into the blocks, disable what is on the homepage and create a new custom HTML blocks
- use panels to create and arrange custom HTML content
However, what happens if the breaking news happens when a developer isn't available or if someone does update the code, but forgets one minor detail that throws off the entire page?
This post will cover three methods of updating homepage layouts without writing code. A developer should be enlisted to help create the initial templates but switching to new layouts can then be done by any content manager.
- View modes
Panels allows site administrators to customize layouts for pages via a drag and drop interface. Combine panels with "views"—Drupal's system for point and click content querying—and a variety of display options can be created.
As a start you'll want some puzzle pieces previously created by your developer: View displays for a couple various image sizes, headline styles, and summary lengths are all great starting points and can be arranged, enabled or disabled via a drag and drop interface.
The panels/views method is a great choice to move content around in an arbitrary manner. The user experience isn't the best though and still could cause some display issues depending on the flexibility each puzzle piece was created with.
In Drupal 7 a new term has been added to our vocabulary. View modes. View modes are basically varying displays of content. In former versions of Drupal a view mode could be considered the full content display or a teaser/summary display. Now the limits to creating these are endless and easy thanks to Display Suite. To change a homepage quickly requires the view modes to be setup in advance and the content manager to know how to change the display output of a view. Though creating view modes is a fairly straightforward it could be a confusing interface to use for someone who hasn't been trained or used the system regularly.
Contexts are the hip thing to do in Drupal now and are a great way to control content on a site. You can easily activate or deactivate and alter accordingly through the default user interface. Simply set-up various templates then activate or deactivate accordingly. The administration screen can become unruly though.
A simple solution to keeping the user in a friendly administration interface is having a developer write a custom module that allows a one-click switch of the homepage with contexts. We'll get into the code for that in a future blog post. The benefits of this method allow a user to select a context either by name or visually if setup with screenshots. After selection is made a simple save will start the process of activating and deactivating contexts automatically.
Whatever method fits right for you should be thought of in advance. Don't wait until the breaking event happens to experiment. Make a plan and come up with some templates you'd like to use. When the time comes you might change pieces to fit the needs of the circumstances, but you'll have a good start and a quick method for changing your homepage.