Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
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
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
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, breakby, 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
Re: accordion yearly menu
Thanks so much abu. I managed to get rid of jquery only a couple of months ago.
Stef.
Your recommendation gives me some ideas. I’ll report back with the progress.
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: accordion yearly menu
colak wrote #343320:
I managed to get rid of jquery only a couple of months ago.
One of my next projects.
Offline
Re: accordion yearly menu
What if you create an accordion-item form
<div class="accordion-item" id="year_<txp:yield item="breakby" />">
<a href="#year<txp:yield item="breakby" />" class="accordion-header"><txp:yield item="breakby" /></a>
<div class="accordion-content">
<ul><+></ul>
</div>
</div>
and then call
<txp:article_custom section="projects" limit="0" breakby="<txp:posted format='%Y' />" breakform="accordion-item" wraptag="div" class="accordion">
<li><a href="<txp:permlink />" rel="bookmark"><txp:title /></a></li>
</txp:article_custom>
Offline
Re: accordion yearly menu
abu wrote #343321:
One of my next projects.
You can do that by utilizing the built-in filter for txp:article:
<!-- year link -->
<txp:site_url />/index.php?s=<txp:section />&month=2025
<!-- month link -->
<txp:site_url />/index.php?s=<txp:section />&month=2025-01
A standard txp:article tag will filter the articles by the corresponding YYYY-MM combination.
TXP Builders – finely-crafted code, design and txp
Offline
Re: accordion yearly menu
jakob wrote #343323:
You can do that by utilizing the built-in filter for txp:article:
A standard txp:article tag will filter the articles by the corresponding
YYYY-MMcombination.
Interesting idea. I’ll take a look into it. Thanks.
Offline
Re: accordion yearly menu
etc wrote #343322:
What if you create an
accordion-itemform
Yes! That’s the sort of thing I meant. But that’s way more elegant and doesn’t even need <txp:if_different>. Awesome.
I need to bookmark this pattern or put it somewhere handy, because it’s something I do quite a lot and I always forget how. Thank you.
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
Pages: 1