Frequently asked questions, or FAQ for short, are fairly common on websites these days. A good FAQ page can help in reducing the number of support requests for basic questions. Whenever I need help on a website, the first thing I look for is the FAQ page before I contact them.
In Drupal, a FAQ page can be created in a few ways. First, you could write the HTML and anchor tags by hand or you could use a module like FAQ Field.
The FAQ Field module comes with a custom field called “FAQ Field” which you can add to any type of entity. It also has a few handy formatters to display the FAQ.
I should also mention that you can use the FAQ module to create these pages. The biggest difference is that the FAQ module has its own content type, whereas, the FAQ Field is based around a field. This is useful for creating FAQs on a Product content type.
In this tutorial, you’ll learn how to setup and use the FAQ Field module. We’ll add the field to the “Basic page” content type that comes with the standard installation of Drupal.
To get going simply download and install the FAQ Field module.
If you use Drush, run the following command:
drush dl faqfield drush en faqfield
Create FAQ Field
As mentioned in the introduction, we’ll create a FAQ field on the “Basic page” content type. Once created, we’ll display the list of questions on a basic page.
1. Go to Structure, “Content types” and click on “manage fields” on the “Basic page” row.
2. Create a FAQ field using the values defined in Table 1.0.
Table 1-0. Create FAQ field
|Field type||FAQ Field|
3. For now, leave the field settings as is and click on “Save field settings”.
4. On the field edit page, you have a few options which can be configured, the most important is the “Answer widget”. This allows you to change what the answer form element will look like.
Textarea: This option allows you to enter an answer using a basic textarea form element.
Formatable textarea: This option is similar to the Textarea, however, it allows you to select a different text format for each answer.
Textfield: This option, as you may have guessed, allows you to enter an answer using a textfield form element.
The module gives you a lot of flexibly on how the answer should be handled. So play around with the different widgets and see which one you prefer.
5. Now that we’ve configured the field, let’s add some FAQs to the bottom of a “Basic page”.
Once you’ve created a few, your page should look something like this:
By default, the formatter displays the FAQ as an accordion. In the next section we’ll look at how you can change the look and feel of the FAQ.
At this point we added a FAQ field to the “Basic page” content type and saw how it was rendered. Let’s now look at the other formatters which you can use.
1. Go to Structure, “Content types” and click on “manage display” on the “Basic page” row. The module comes with four formatters: Accordion, “Simple text (themeable)”, “Definition list” and “Anchor list and text”.
2. Select “Anchor list and text” from the drop-down and click on Save. This formatter will render the FAQ with the questions at the top and answers below which is the common look and feel for FAQ listings.
3. Now if we go back to our page, the FAQs will be displayed differently.
Indexing Questions and Answers using Search API
I’ve written a few tutorials on using Search API for building search pages. It’s my preferred way of creating powerful search pages in Drupal. Luckily, you can index the individual question and answer field on a FAQ field using Search API.
To index the FAQ field, just click on “Add related fields” in the Fields tab on your Search API index. Then select your FAQ field and click on “Add fields”.
Once the field has been added to the index, you must check the question and answer field in the Fields table.
And finally, don’t forget to re-index your content.
I like FAQ Field because its functionality is wrapped in a field instead of a content type and this allows you to add a FAQ section to any entity type by simply attaching a field. As shown above, there’s integration with Search API out-of-the-box.
4 thoughts on “Create a Frequently Asked Questions Page Using FAQ Field in Drupal 7”
Hi, Ivan! I think, Double Field module will be more interesting.
Thanks, I’ll check out the module.
Try to put all the FAQ into one page, how to do it? Thanks.
Sorry I don’t understand your question. The FAQs are rendered from a field which only appears on a single page. They are already displayed on a single page.