Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-12-09 10:48:31

pieman
Member
From: Bristol, UK
Registered: 2005-09-22
Posts: 491
Website

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

#2 2009-12-09 11:51:00

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

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

#3 2009-12-09 11:55:56

pieman
Member
From: Bristol, UK
Registered: 2005-09-22
Posts: 491
Website

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

#4 2009-12-09 12:15:15

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

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

#5 2009-12-09 12:20:55

pieman
Member
From: Bristol, UK
Registered: 2005-09-22
Posts: 491
Website

Re: Archive Links by date (without breaking the internet)

OK, the penny dropped now. Thanks :)

Offline

Board footer

Powered by FluxBB