Over the last couple of weeks, several different OSTraining members have asked me about creating a directory in Drupal.
I’m going to recommend a 4-step process for creating a basic directory.
Using default Drupal, plus the Display Suite and the Search API modules, we can create almost any type of directory.
Step 1: Create the Content type
First we need to set up our content type for the directory.
In this example, I’m going to build a business directory.
I’m going to create one content type for all our businesses. However, if the different items in your directory require radically different fields, you might consider creating multiple content types.
The image below is an example of the fields added to this content type:
The final field, “Type of Business” is a taxonomy. I’ve set this up as a Taxonomy to give me maximum flexibility in the future:
If you’re taking submissions from the public, read our article “Clean Up the Drupal Content Form” which shows you how to make it easier for new Drupal users.
Step 2. Import Data
You will need to get some data into your site so that you can build the directory. You have at least three options here:
- Manually enter the business data
- Use the Devel module to generate dummy data
- Import data from a CSV file using the Feeds module
In this example, I used the Devel module to create some “Lore Ipsum Dolor” businesses:
Step 3. Improve the Directory Pages
Once we have content loaded into our site, we can browse and see our directory starting to take shape.
However, by default, all of the individual pages will look fairly plain. For example, here is the page listing all the bakers in our directory:
One way to improve the display of these pages is with the Display Suite module. You can watch our full class on Display Suite by clicking here.
With Display Suite, you can control the layout of the page seen above by controlling the Teaser format.
In the example below, I used Display Suite to change the layout to a 3-column design:
Step 4. Filters with FacetAPI
One final step towards creating a good directory is adding powerful search features.
We recommend using the Search API and Facet API modules. Click here to see our full class on creating powerful search with these modules.
Here’s an image from Wunderkraut of a faceted search created with the FacetAPI module:
And here’s a video from our Search class illustrating how to use the Facet API module: