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.

FAQ page

May 06, 2011 12:16pm

Subscribe [2]
  • #1 / May 06, 2011 12:16pm

    marianway

    24 posts

    Hello,

    I am making an FAQ page with a list of questions at the top, followed by the questions again, with their answers. I would like to be able to click on a question and it take me to the relevant question+answer below. I have seen this on loads of sites, so I am thinking it must be easy, but I don’t know how to create the links.

    The code I have is:

    <ul>
    {exp:weblog:entries weblog="faq" category="37|38|39" sort="asc" disable="categories|member_data|pagination|trackbacks"}
    <li>{title}</li>
    {/exp:weblog:entries}</ul>

    {exp:weblog:entries weblog="faq" category="37|38|39" sort="asc" disable="categories|member_data|pagination|trackbacks"}

    {title}

    {g_body}
    {/exp:weblog:entries}

    This all outputs to the page ok, except of course there are no links!

    I would be grateful for any pointers.

    With best wishes

    Marian

  • #2 / May 06, 2011 12:22pm

    Rob Allen

    3118 posts

    You can usually do this by using # anchors in the links, so try this…

    In your first list make each title into a link and generate a unique ID for each title:

    <ul>
    {exp:weblog:entries weblog="faq" category="37|38|39" sort="asc" disable="categories|member_data|pagination|trackbacks"}
    <li><a href="#go{entry_id}">{title}</a></li>
    {/exp:weblog:entries}</ul>

    Then for each faq entry you need to wrap the title in a tag and give it a corresponding ID:

    {exp:weblog:entries weblog="faq" category="37|38|39" sort="asc" disable="categories|member_data|pagination|trackbacks"}
    <h3 id="go{entry_id}">{title}</h3>
    {g_body}
    {/exp:weblog:entries}
  • #3 / May 06, 2011 3:02pm

    marianway

    24 posts

    Thank you so much! This worked beautifully!
    Marian

  • #4 / May 06, 2011 3:06pm

    Rob Allen

    3118 posts

    Glad you got it sorted 😊

  • #5 / May 07, 2011 11:04am

    Sue Crocker

    26054 posts

    Thanks for the assist, Rob.

    marianway, sounds like you’re all set. Don’t hesitate to post again as needed.

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

ExpressionEngine News!

#eecms, #events, #releases