Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
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
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
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
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
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
Re: How do I Sort by Custom Date field?
That’s a great idea. How do you do that?
Offline
Re: How do I Sort by Custom Date field?
Click the “More” link in the Write tab …
Code is topiary
Offline
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
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
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.
Offline
Re: How do I Sort by Custom Date field?
And alternatively, smd_horizon
Offline
Re: How do I Sort by Custom Date field?
It’s working well. Thanks, everyone!
Offline
Pages: 1