Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2023-02-25 19:49:19

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,137
GitHub

Detecting existence of articles for a given date, month & year

I’m trying to reverse-engineer some blog sidebar furniture from time gone by: links to articles on a given date, or month / year. I’m not getting very far in how this plugs together, so I’m here with a polite request for some guidance.

The ones I’ve seen usually have a list of days or months, sometimes in a month-view calendar or diary format, where the date is hyperlinked to the article(s) for that day. If the month-view calendar doesn’t have any articles for that date, the date isn’t hyperlinked. How on earth is this achieved without chewing through a database with queries? I’d really appreciate a pointer for some further reading, if such a thing exists.

Thank you.

PS: I even went to Textplates(.com) to find some old-old templates to pull apart, but alas it’s fallen to bit-rot and the themes (& associated previews) aren’t accessible.

Offline

#2 2023-02-25 20:06:59

etc
Developer
Registered: 2010-11-11
Posts: 5,053
Website GitHub

Re: Detecting existence of articles for a given date, month & year

Year-month is easy. The main problem of month-day archives is the calendar grid. Once it is constructed, filling it is with links is straightforward.

Offline

#3 2023-02-26 13:40:32

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,137
GitHub

Re: Detecting existence of articles for a given date, month & year

Thank you, etc – perfect.

Offline

#4 2023-02-27 12:29:21

etc
Developer
Registered: 2010-11-11
Posts: 5,053
Website GitHub

Re: Detecting existence of articles for a given date, month & year

Just for the record, if you only want to count Y-m-d articles, no plugin is needed:

<txp:article_custom fields="DATE[%Y-%m-%d](posted)" limit="0">
    <txp:posted format="%Y-%m-%d" /> (<txp:yield item="count" />)
</txp:article_custom>

Offline

Board footer

Powered by FluxBB