Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Archive Links by date (without breaking the internet)
A site I’m working on needs a ‘microblog’ and I’m weighing up the relative merits (& complexities) of using either Delicious or Txp Links.
One key factor is that we’ll need to generate a date-based archive of old entries. All the existing archiving plugins I can find are explicitly for use with articles rather than links.
I can imagine it’ll be possible to display date-sensitive links by pulling a year from the URL and using smd_query
. But how to generate the archive navigation?
My first thought is to invoke the power of if_different
to return one item for each year in which a link has been saved.
<ul>
<txp:linklist form="links_nav" sort="date" />
</ul>
in links_nav
<txp:if_different><li><a href="/links/<txp:link_date format="%Y" />"><txp:link_date format="%Y" /></a></li></txp:if_different>
It seems to work nicely, but I have only five links in the db in this test.
Now I’m a bit of an eejit when it comes to server-side performance tactics, but even I can see that this will be a ridiculously inefficient way to output a small menu when there are 2-300, or even 2-3000 links saved.
Is there another (better) way?
Offline
Re: Archive Links by date (without breaking the internet)
pieman wrote:
Is there another (better) way?
No. Not with native markup.
It is going to be a bit slow if and when the list goes looong, and the more containers you use, the more performance it will eat. But, you can do nothing to it — except using PHP or SQL (smd_query/rah_function) instead TXP markup.
The key is grouping things:
[...]group by date order by date desc[...]
Last edited by Gocom (2009-12-09 11:52:03)
Offline
Re: Archive Links by date (without breaking the internet)
Gocom wrote:
The key is grouping things:
[...]group by date order by date desc[...]
Thanks Jukka. Sorry to be slow – can you explain what you mean here?
Offline
Re: Archive Links by date (without breaking the internet)
pieman wrote:
Thanks Jukka. Sorry to be slow – can you explain what you mean here?
Let me quote me:
SQL (smd_query/rah_function) instead TXP markup.
To it being faster, you can rely on SQL’s grouping instead of, emhumm-urgh, after grouping with PHP (if_different).
Offline
Re: Archive Links by date (without breaking the internet)
OK, the penny dropped now. Thanks :)
Offline