ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Help with creating an FAQ section please?

February 25, 2012 9:58am

Subscribe [4]
  • #1 / Feb 25, 2012 9:58am

    Mark Bowen

    12637 posts

    Hiya,

    I’m probably just having a brain drain here but was wondering about the best way to do something so thought I’d come here and ask the fantastic community 😊

    I need to create an FAQs section on a website (running ExpressionEngine 1.x). Currently it’s all working fine with a list of questions at the top of the page which when clicked scroll the page to the question and answer. This is using two Weblog Tags to allow me to do this, one to show the questions at the top of the page and one to show the question / answer lower on the page.

    I now need to throw categories into the mix (only two at this stage but possibly more in the future so need it to be dynamic) and would like to somehow split up the questions at the top of the page into their respective categories however if I use the Weblog Category Archive Tag I can’t then make my anchor links as there is nothing like {entry_id} available with which to make the links.

    Currently the links for the questions look like this :

    <a href="#answer_{entry_id}" title="Show Answer">Title Of Question Here</a>

    With no {entry_id} available or anything else that could make these links in that way I can’t therefore use the Category Archive Tag so am wondering if there’s some other / better way of laying all of this out?

    Hopefully someone understands what I’m asking here and has some ideas on this one.

    Thanks in advance for any help / ideas on this one.

    Best wishes,

    Mark

     

  • #2 / Feb 25, 2012 10:03am

    Sean C. Smith

    3818 posts

    Hi Mark,

    What I did on an old site I built in EE 1.6.x was to use matrix with each row being a question and an an answer. Each entry was then a category/section of the faq.

    If you haven’t done all the data entry already, then it might be worth restructuring the FAQ.

  • #3 / Feb 25, 2012 10:41am

    Mark Bowen

    12637 posts

    Hi Sean,

    Do you have a link to the site at all? Just wondering what you mean by below :

    Each entry was then a category/section of the faq.

    What I’ll have is say 20 questions that are in one category and then say 30 questions in another category. Not too sure how each question being a separate category will help here?

    Thanks,

    Mark

     

  • #4 / Feb 25, 2012 10:53am

    Sean C. Smith

    3818 posts

    Mark,

    That site is now dead.

    What I mean is one entry with a matrix field where the matrix field can have as many FAQ Questions.

    so the entry could contain all faq questions in the category “Sales” , say 6 questions, one each a row in the matrix field. And then the next entry would be questions about “Shipping” containing perhaps 3 rows.

    {exp:weblog:entries channel="faq"}
    
    <h3>{title}</h3>
    <p> {faq}<br />
      {question}<br />
      {answer}<br />
     {/faq}<br />
    {/exp:weblog:entries}

    The above would list out all questions and answers below the Entry title for each section of the FAQ. now of course you’ll need to fix this up to do what you want. Where you would have one section that would list only the questions and link to the answers below using {row_id} (I believe that’s correct).

    Does this help?

    Sean

  • #5 / Feb 25, 2012 11:43am

    Mark Bowen

    12637 posts

    Hi Sean,

    Ah I see what you meant now. One entry per category. A good idea however there could end up being a lot of questions for each category and there would probably end up being more fields in each question so a Matrix type of effect here probably wouldn’t be the best thing to do due to possible memory issues in the backend.

    I also prefer to keep things separate when it comes to entries like this. I’ll probably just end up going with a page per category instead but if you or anyone else has any other ideas I’m open to hearing them.

    Thanks again for chiming in and the idea there.

    Best wishes,

    Mark

  • #6 / Feb 25, 2012 11:47am

    John St-Amand

    865 posts

    Hi Mark - Sean’s suggestion would definitely work.  Another way you could go is to next an entries loop within the weblog categories tag pair.  It’s certainly not the most performance friendly way to go about it, but if the number of categories is not all that big ultimately, then some template and entries caching can make up for that performance drain - or at least some of it.  Doing it that way, you get the whole suite of entries variables available to you, including that all important entry_id for your bookmark link.  So for your list of questions at the top, something like this:

    {exp:weblog:categories weblog="faq" style="linear" show_empty="no" disable="category_fields"}
    <h2>{category_name}</h2>
    <p><ul><br />
    {exp:weblog:entries weblog="faq" category="{category_id}" disable="trackbacks|member_data|pagination|categories"}<br />
        <li><a href="#answer_{entry_id}" title="Show Answer">{title}</a></li><br />
    {/exp:weblog:entries}<br />
    </ul><br />
    {/exp:weblog:categories}

    Hope that helps!

  • #7 / Feb 25, 2012 11:53am

    Mark Bowen

    12637 posts

    Hi John,

    Yep I know Sean’s idea would definitely work and in other places it might be something I’d go for however I really don’t think in this case that having all the questions contained in one entry would be best for this site. What you’ve shown above would probably work too however I’m not really a fan of embedding tags like that wherever I can help it as in the past they’ve always come back to bite me in the bot**m as it were 😉

    I think for this project just to keep it all safe and easy for me and more importantly the client I’m just going to have a separate page for each category. That way everything is stored the way I want it to be and can also be displayed 90% of the way I’d like it to be also.

    Thanks for the extra thoughts there though as they’re much appreciated.

    Best wishes,

    Mark

  • #8 / Feb 25, 2012 11:53am

    John St-Amand

    865 posts

    Another thing I can suggest, and this would be a change from what you’re doing now, would be a jQuery show/hide function on click of the question.  If you did it that way, you’d only have one loop through the categories.  But obviously is a bit less simple than straight forward bookmarks.  I’ve done it both ways in the past.

  • #9 / Feb 25, 2012 11:59am

    John St-Amand

    865 posts

    Yeah, I’m not a fan of the embedded tags either.  I’ve used them reluctantly in the past, but I probably wouldn’t choose to go that route often. If a separate page per category will work for you, then that sounds like a solid approach.  It’s really surprising that entry_id isn’t available in the category archives loop, especially given that entry_id_path IS.

  • #10 / Feb 25, 2012 2:08pm

    Justin Long

    196 posts

    I will have to check when I get home (posting from an iPhone atm) but I believe I did something similar to

    {exp:channel:category_archive channel="faqs" style="linear"}
        {categories}
            <h3>{category_name}</h3>
    <p>    {/categories}<br />
        {entry_titles}<br />
            <a href="http://{entry_id_path=" title="Show Answer">Title Of Question Here</a> </p>
    
    <p>    {/entry_titles}<br />
    {/exp:channel:category_archive}

    on a site in the past and it worked out for me.

    EDIT**
    It seems that it is stripping out the entry_id_path=”#anwsers_”


    http://pastie.org/3457542 of the full template code

  • #11 / Feb 26, 2012 6:59am

    Mark Bowen

    12637 posts

    I will have to check when I get home (posting from an iPhone atm) but I believe I did something similar to

    {exp:channel:category_archive channel="faqs" style="linear"}
        {categories}
            <h3>{category_name}</h3>
    <p>    {/categories}<br />
        {entry_titles}<br />
            <a href="http://{entry_id_path=" title="Show Answer">Title Of Question Here</a> </p>
    
    <p>    {/entry_titles}<br />
    {/exp:channel:category_archive}

    on a site in the past and it worked out for me.

    EDIT**
    It seems that it is stripping out the entry_id_path=”#anwsers_”


    http://pastie.org/3457542 of the full template code

    Looks neat however I’m getting links rendered like this :

    <a href="http://www.example.co.uk/#answer_/1929/">http://www.example.co.uk/#answer_/1929/</a>

    Because of the extra slash before the entry_id they’re not working as anchors :-(

    Mark

  • #12 / Feb 26, 2012 7:34am

    Mark Bowen

    12637 posts

    Hmm that’s a bit weird. If I make the answers anchors look like this :

    <a name="answer_/{entry_id}"></a>

    They work if you copy and paste the link into the address bar and scroll to the right place but not if you click on the links.

    A bit weird that one.

    Mark

     

  • #13 / Feb 27, 2012 10:36am

    ChiefAlchemist

    913 posts

    I’m reading this all very quickly so pardon me if I’m off target.

    Question
    .
    .
    .
    <div id=“anchor_{entry_id}”>Answer…</div>

    I was also always under the impression that CSS id and class can’t start with a number.

    btw, I have a jQuery plugin (in beta) that makes it EZ to markup those links so you can Event Track them in Google Analytics. In other words, the client would be able to see which questions are being looked at the most often.

    Minor? Perhaps. But none the less helpful. e.g., Maybe the question should be reorder to reflect need? 20 is a pretty long list and what if the most sought after Q&A is buried at #15?

    I can post the link here if anyone is interested and won’t be offended by my shameless self-promotion 😉

  • #14 / Feb 27, 2012 10:55am

    Mark Bowen

    12637 posts

    Yep a little off-target.

    I did originally have the link as

    #anchor_{entry_id}

    but as mentioned above couldn’t use {entry_id} in conjunction with the Category Archive Tag as it doesn’t have that variable available to it.

    Using {entry_id_path} causes there to be a slash like you’re querying above.

    Mark

  • #15 / Feb 27, 2012 11:37am

    ChiefAlchemist

    913 posts

    Sorry ‘bout that.

    You want to assign categories to each entry in the FAQ weblog.

    You want to display those those grouped by category.

    Correct?

    I hate to just toss this over the wall at you but:

    http://chiefalchemist.com/expression-engine-nested-category-pairs/

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases