0

Client wants a blog archive with the posts inside accordions whose toggle is the year. Two example years HTML below.

I have the individual fields exposed as tokens within my view with no problem. What I can't see how to do is to enable conditional logic so I express the Year toggle structure once per year of posts.

Is this possible with a View?

I went over Blog monthly archive block - list of posts grouped by year then month I read the 10 year old post at http://chrisshattuck.com/blog/how-create-monthly-archive-block-drupal-blog-views

I have a working view Block but not nesting the way I need it. It outputs a whole accordion per post (as I knew it would).

<div class="fcx-accordion" id="accordion">

<h4 class="fcx-toggle"><a data-toggle="collapse" href="#list2019">2019</a></h4>
<div class="panel">
    <div class="accordion-content panel-collapse collapse" id="list2019">

        <ul>
            <li>{Authored on} - {Linked title}</li>
        </ul>

    </div>
    <!-- accordion-content -->
</div>
<!-- panel-->
<h4 class="fcx-toggle"><a data-toggle="collapse" href="#list2018">2018</a></h4>
<div class="panel">
    <div class="accordion-content panel-collapse collapse" id="list2018">

        <ul>
            <li>{Authored on} - {Linked title}</li>
        </ul>

    </div>
    <!-- accordion-content -->
</div>
<!-- panel-->

1 Answer 1

2

You can do this with the Views Accordion module.

Add the Authored on field, choose the formatter that only shows the year of the created date. Then edit the Format settings to set the Grouping field Nr.1 field to your yearly Authored on field.

This way you get all the results split into groups by year.

Now you configure the Views Accordion to use the Grouping as accordion headings and the grouped results as accordion content.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.