October 5th, 2008

Simple FAQ page for ExpressionEngine

Just to show how easy ExpressionEngine makes many things:

A client asked for an FAQ page.  30 minutes later and it’s done (the majority of that time spent on changing some of the CSS file).  This is how I did it (note, this is just one way, there are probably better ways and certainly you can do clever things with javascript, but this way is simple and works well):

  1. Set up new weblog called “faq”.
  2. Set up a new custom field group called FAQ.  There is only one field, “answer”.  The title of the entry will be the question (title is a default field for every weblog so you don’t need to add it to the field group).
  3. Assign the FAQ field group to the faq weblog.
  4. Add a test question.
  5. Set up your template:

    <a name="top"></a>
        
    {!-- The titles of the faq weblog are the questions --}
        {exp
    :weblog:entries weblog="faq" disable="member_data|comments|trackbacks|pagination"}
        
    <h3 class="font_5"><a href="#{title}">{title}</a></h3>
        
    {/exp:weblog:entries}

        {
    !-- Answers go here --}
        
    <ul class="list_3">
            
    {exp:weblog:entries weblog="faq" disable="member_data|comments|trackbacks|pagination"}
        
    <li>
            <
    a name="{title}"><h3 class="font_5">{title}</h3></a>
            
    {answer}
            
    <a href="#top">Back to top</a>
        </
    li>
        
    {/exp:weblog:entries}
        
    </ul>

Notes

  • You could use the {entry_id} as a unique identifier for the anchor link for each question; I used the {title} field so that the FAQs can also be listed by category (the categories tag pair does not give you access to the {entry_id} tag).
  • The unordered list markup is useful for CSS styling, but it’s not required for the template to work.
  • You can change the order of display of the FAQs by changing the dates on their entries. You can also order alphabetically etc.
  • If you have a lot of FAQs, you could group them by adding categories.

That’s it!  You can see the finished product here: http://www.hotbod.co.nz/index.php?/site/faq.

Comments are closed

I'm sorry, but comments for this entry are currently closed.

There are no comments for this entry.

Commenting is not available in this weblog entry.

Categories