Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2010-10-06 15:44:53

bluepurl
Member
From: Prairie du Sac, Wi
Registered: 2009-02-23
Posts: 42
Website

How do I Sort by Custom Date field?

I’ve installed glz_custom_field plugin, but the sort for my articles is still by posted date not by custom_field date.

I’m not really sure if it’s the right plugin for the job. Am I on the right track? Am I stupidly missing something simple?

Offline

#2 2010-10-06 15:59:28

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: How do I Sort by Custom Date field?

What’s your sort value? Should be the database column name (like ‘custom_6’), not the name you’ve assigned to the custom field.


Code is topiary

Offline

#3 2010-10-06 23:38:42

aslsw66
Member
From: Canberra, Australia
Registered: 2004-08-04
Posts: 342
Website

Re: How do I Sort by Custom Date field?

I’ve come across this before and I think the simple answer is that you can’t.

Custom fields store all of their content as text (it’s how they are defined in the database). Although the custom fields give wonderful options for how to get values into a custom field, in the end they are still just text.

And sorting on text will always give a different result to sorting on a true date field.

Which is why I have reverted to using the posted date as the date of an event.

Of course, if anyone has managed to solve this problem then I am happy to be wrong!

Offline

#4 2010-10-07 14:15:41

bluepurl
Member
From: Prairie du Sac, Wi
Registered: 2009-02-23
Posts: 42
Website

Re: How do I Sort by Custom Date field?

Thanks for the advice. I’m creating a site for a foodie-oriented festival that is six weeks long and includes many different tastings, workshops, etc. My hope is to have a a schedule section with a landing page that is a list of all the events sorted in chronological order. When visitors click on the title of the event, they go through to an article with more detail for the particular event.

I think what I’m going to do is have two fields. One will be a sort field that will not actually appear on the schedule page. It will just be used when writing articles to put in a sort value. The other field, which will appear, will contain the date in text format. I’ll make a chart which matches each sort value to a date – on paper, lol – and use it to match things up when writing articles.

It’s a little kludgy, but I’m pretty sure my client wouldn’t want to pay to hire a guru to figure this out. They are on a strict budget.

BTW, jsoo, my initial problem was, in fact, putting the name of the custom field, rather than “custom_x” in the declaration. Thanks for the tip.

Offline

#5 2010-10-07 14:29:26

Dragondz
Moderator
From: Algérie
Registered: 2005-06-12
Posts: 1,549
Website GitHub Twitter

Re: How do I Sort by Custom Date field?

Hi Ann

Why not use the article’s posted date for that purpose? you only have to set it on article write page, by default it s set to now, but you can change it to what ever you want.

Offline

#6 2010-10-07 15:30:52

bluepurl
Member
From: Prairie du Sac, Wi
Registered: 2009-02-23
Posts: 42
Website

Re: How do I Sort by Custom Date field?

That’s a great idea. How do you do that?

Offline

#7 2010-10-07 15:35:53

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: How do I Sort by Custom Date field?

Click the “More” link in the Write tab …


Code is topiary

Offline

#8 2010-10-07 17:16:53

nabrown78
Member
From: Northampton, MA, USA
Registered: 2006-10-04
Posts: 294
Website

Re: How do I Sort by Custom Date field?

A great trick is to also set the expiration date to the time/date when the particular event ends. That way you can move it to a “past events” section or remove it from the site altogether.

Offline

#9 2010-10-08 12:49:28

bluepurl
Member
From: Prairie du Sac, Wi
Registered: 2009-02-23
Posts: 42
Website

Re: How do I Sort by Custom Date field?

Thanks, everyone. Found the More tab (oh, that more tab) and thus how to change the posted date. Yay.

However, when I change it to a date that is in the future (as all of these dates are) article doesn’t appear. Do you know of a plug-in that will enable me to post future dated articles?

Offline

#10 2010-10-08 12:57:45

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: How do I Sort by Custom Date field?

Hi Ann,
you could try time="future" in your txp:article tag.
Alternatively, you can unleash the power of time-controlling with smd_calendar. Be careful: it’s the equivalent of a Delorean time machine.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#11 2010-10-08 14:48:32

maverick
Member
From: Southeastern Michigan, USA
Registered: 2005-01-14
Posts: 976
Website

Re: How do I Sort by Custom Date field?

And alternatively, smd_horizon

Offline

#12 2010-10-08 15:17:29

bluepurl
Member
From: Prairie du Sac, Wi
Registered: 2009-02-23
Posts: 42
Website

Re: How do I Sort by Custom Date field?

It’s working well. Thanks, everyone!

Offline

Board footer

Powered by FluxBB