Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 Today 07:54:36

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,412
Website GitHub Mastodon Twitter

accordion yearly menu

I’m trying to create an accordion yearly menu but I cannot think of an economical way of constructing it. At the moment I have the following which is really bad as it needs to go back to 2006. Can anyone recommend a more efficient/automated way of doing it?

<div class="accordion">
  <div class="accordion-item" id="year_2026">
    <a href="#year2026" class="accordion-header">2026</a>
    <div class="accordion-content">
        <txp:article_custom month="2026" limit="999" section="projects" break="li" wraptag="ul">
            <a href="<txp:permlink />" rel="bookmark"><txp:title /></a>
    </txp:article_custom>
    </div>
  </div>

  <div class="accordion-item" id="year_2025">
    <a href="#year2025" class="accordion-header">2025</a>
    <div class="accordion-content">
      <txp:article_custom month="2025" limit="999" section="projects" break="li" wraptag="ul">
            <a href="<txp:permlink />" rel="bookmark"><txp:title /></a>
      </txp:article_custom>
    </div>
  </div>

  <div class="accordion-item" id="year_2024">
    <a href="#year2024" class="accordion-header">2024</a>
    <div class="accordion-content">
      <txp:article_custom month="2024" limit="999" section="projects" break="li" wraptag="ul">
            <a href="<txp:permlink />" rel="bookmark"><txp:title /></a>
      </txp:article_custom>
    </div>
  </div>
</div>

Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#2 Today 09:03:31

abu
Plugin Author
From: Switzerland
Registered: 2025-04-03
Posts: 17
GitHub GitLab Mastodon

Re: accordion yearly menu

I did something like this in my plugin abu_archtree, but it currently needs jQuery.

For a live demo, you might take a look at my site.

Last edited by abu (Today 09:31:48)

Offline

#3 Today 11:23:59

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,580
Website GitHub

Re: accordion yearly menu

Can you use article_custom with limit="0" sort="Posted desc" to get everything in that section in date order, and then use breakform to split it?

Inside the form, it might be possible to use <txp:if_different><txp:posted format="%Y" /></txp:if_different> and <txp:if_different><txp:posted format="%m" /></txp:if_different> to spit out your/month wrapper tags and headings.

It might not be easy because you need to top and tail it with markup each time it changes, and I’ve had a devil of a time trying to do that in the past. But between the container, breakform and the spaceship <+> it might be possible to fashion some reusable ‘cards’ that you can build and inject where you need them in the list.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Hire Txp Builders – finely-crafted code, design and Txp

Offline

Board footer

Powered by FluxBB