Skip to main content
edited title
Link
leymannx
  • 18.8k
  • 6
  • 72
  • 126

View of blog posts with grouped by year

edited title
Link
leymannx
  • 18.8k
  • 6
  • 72
  • 126

D8 View of Blog Postsblog posts with Year Heading Followed By Posts From Yeargrouped by year

Source Link

D8 View of Blog Posts with Year Heading Followed By Posts From Year

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-->