Last updated June 7, 2014. Created on July 11, 2011.
Edited by acabouet, wmostrey, cgroche, xenophyle. Log in to edit this page.

Here is a recipe for creating a FAQ using nodes and Views. I did this in Drupal 7 but it should work in D6 also, although some steps will be different due to the new D7 user interface.
I am using the Administration Menu module with the Administration menu Toolbar style submodule enabled, and my directions to navigate to pages reflect that.
You will need the Token module installed.

Step 1: Create the FAQ content type

FAQ Content Type

  1. Go to Structure -> Content types -> Add content type.
  2. Give the content type the name "FAQ".
  3. Change the title field label to "Question"
  4. I recommend unchecking "Promoted to front page" and "Display author and date information" and disabling comments.
  5. Save the content type and go to "Manage fields"
  6. Delete the body field.
  7. Add a new field called "Answer" of type long text (i.e., an html textarea)
  8. Here are the settings I used for the Answer field:
    • Check required field
    • 20 Rows
    • Text processing: Filtered text
    • Number of values: 1
  9. If you want to be able to control exactly what order the FAQs are shown in, you could also add an integer field called "Sort order".

Step 2: Create some FAQ nodes

FAQ Nodes

  1. Go to Content -> Add content -> FAQ.
  2. Fill in the question and answer fields and save.

Step 3: Create Views

FAQ Views
Now we will create two views (actually two displays in one view): one for the table of contents and one for the full-body list of the FAQs. One display will be a page and the other can be an attachment or a block. I found using a block makes it easier to apply the desired CSS, since using an attachment marks up the page as one view inside another.

Initial view configuration

Here is where there is a difference between D6 and D7. In Drupal 7 I needed to make the table of contents the block view and make the full-body faq list the page view, since the block is rendered above the page display. I believe (but haven't confirmed) in D6 you would do the reverse: the table of contents would be the page view.

  1. Go to Views-> Add new view
  2. On the configuration page that takes you to:
    1. Call the view "FAQ".
    2. Show content of type FAQ sorted by (your desired sort order)
    3. Create a page
      • Page title: Frequently asked questions
      • Path: faq
      • Display format: HTML list of fields
      • Items to display: (leave blank)
      • Create a menu link (if desired) in the desired menu (probably Main) with Link text: FAQ
    4. Create a block
      • Block title: (Title of your choice)
      • Formatted list of titles
      • Items per page: (leave blank)
    5. Continue and edit

Table of contents display configuration

This will create a list of the questions that link to the full FAQ node farther down on the page.
In the "Fields" section

  1. Add field: Global: View result counter
  2. Check "Exclude from display"
  3. Starting value: 1
  4. Edit field: Title
  5. Uncheck "Create a label"
  6. Under "Rewrite results", check "Output this field as a link" and set link path as faq#[counter]

In Drupal 6 the result counter field will need to come before the title.

Full-body display

In the "Fields" section

  1. Add field: Global: View result counter
  2. Check "Exclude from display"
  3. Starting value: 1
  4. Edit field (or create if not there): Title
  5. Uncheck "Create a label"
  6. Under "Rewrite results", check "Rewrite the output of this field" and set Text to <a name="[counter]">[title]</a>
  7. Add field: Content: Answer
  8. Uncheck "Create a label"
  9. (Optional: link back to top of page) Add field: Global: custom text
  10. Uncheck "Create a label"
  11. Set Text to <a href="faq#main-content">Back to Top</a>

Step 4: Configure block

  1. Go to Structure->Blocks
  2. Find your new block and move it into the Content section (assuming your theme has a region called "content")
  3. Show the block only on the lists pages: faq
  4. Save block

Looking for support? Visit the forums, or join #drupal-support in IRC.


ajmartin’s picture

I have set this up and it works great, thank you!

There's one thing I'd like to know if possible:
Currently when you click on the links in the block it takes you to the content without refreshing the page - and works perfectly as long as you only click on the links in the block. But when you click on "Back to Top" the page refreshes - now you can click on any "Back to Top link without a page refresh, but when you click on a link in the block the page will refresh again... So site visitors are forced to refresh the page each time they alternate between a click on a content link and "Back to Top".

Is there a setting that would allow navigation without refreshing the page?

Thanks again!

Vandalf’s picture

First, thanks for this description, it works great!
I did a minor tweak though: If you want the title of each faq-item to list to the original faq content page, add the field Content: Path to your fields list on the full-body display. Make sure it's placed above the Content: Title field (if not, rearrange! The replacement patterns only "read" the above listed fields...).
Then tweak the rewrite text under Step 3, Full-body display, point 6 to : <a name="[counter]" href="[path]">[title]</a>
Simple as that :)
Not a necessary change, but thought I'd share it anyway, in case someone wanted to do the same for any reason.

davidjsn’s picture

In views if I add a field, in either the block or the page sections, I automatically get the same field and settings the other section. The result is that I get the answer at the top of the page next to the link. I've been over and over it but don't know how to avoid this.

jenne80’s picture

I also ran into the problem of not being able to get the fields to stay as different settings and ended up having to create the block view and page view separately. This seems to work, but my faq block list is listing all of my content and not just the faqs. Any suggestions on how to fix this?

xenophyle’s picture

When you add or modify a field in a display, you can select "All displays (except overridden)" or "This display". Then it should only affect the display you are editing. Have you tried this?

7drupel7’s picture

Also you can include the Weight module to rearrange the order of the questions in the table of contents.

Just include the Weight field in the Table of contents block as last field y especify the order of the both views (the "table of contents" and the "body display") including the same Weight field but now as first field.

Is necessary to change the format of the view "Table of contents" to "Table" in order to function and include the Weight field in the display, but you can remove the label.

In that way you can drag and reorder your questions within the same page.

Also I recommend to use an "Id" instead of "name" attribute for W3C checking.

eurotyke’s picture

Could someone add some examples of sites that have used this approach?