Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-03-15 11:58:28

Qwest
Member
From: London, UK
Registered: 2007-01-24
Posts: 112

Sort order using a custom date field?

Im putting a “schedule” of events onto my TXP site. It’s gone well so far. Basically, any items i put in my “events” section are displayed on my events page as normal, but are also displayed on the schedule page. However, it only displays the event title (eg: Trinity vs Funkin Serious) and then the event date. Now this is not the date posted, but the date when the event takes place.

I always enter this into my “customfield_eventdate” field so it’s always a constant in that field.

Is there anyway i can get my “schedule page” to sort the events by the customfield event date? Preferably the soonest event at the top.

Any help would be great!! Cheers :)

Offline

#2 2007-03-15 12:18:04

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: Sort order using a custom date field?

Sure if “customfield_eventdate” is the first custom field, then add this to the article tag: sort="custom_1 ASC" or sort="custom_1 DESC"

Last edited by ruud (2007-03-15 12:18:23)

Offline

#3 2007-03-15 12:22:43

Qwest
Member
From: London, UK
Registered: 2007-01-24
Posts: 112

Re: Sort order using a custom date field?

Ruud! Thanks for that, work’s like a charm!….

Now to test you, how can i highlight the first item in that list. Ideally, i want it to stand out, and marked up as “the next event is…” sort of thing?… But only the top item in the list?

Offline

#4 2007-03-15 12:27:08

axueer
New Member
Registered: 2007-03-15
Posts: 7

Re: Sort order using a custom date field?

Qwest ,Are you on line?Can you help me,please?

Offline

#5 2007-03-15 12:31:12

Qwest
Member
From: London, UK
Registered: 2007-01-24
Posts: 112

Re: Sort order using a custom date field?

axueer… What’s the prob?

Offline

#6 2007-03-15 12:35:11

axueer
New Member
Registered: 2007-03-15
Posts: 7

Re: Sort order using a custom date field?

I dont know.I from China.My English is not good.I can use English a little.

Offline

#7 2007-03-15 12:37:22

axueer
New Member
Registered: 2007-03-15
Posts: 7

Re: Sort order using a custom date field?

Sorry,please see the post

http://forum.textpattern.com/viewtopic.php?id=21649

Sorry myEnglish is so bad,can you understand?

Offline

#8 2007-03-15 12:39:13

Qwest
Member
From: London, UK
Registered: 2007-01-24
Posts: 112

Re: Sort order using a custom date field?

What is the problem?.. What do you need help with?

Offline

#9 2007-03-15 12:41:20

Qwest
Member
From: London, UK
Registered: 2007-01-24
Posts: 112

Re: Sort order using a custom date field?

Sorry Axueer, i don’t know about these plug-ins. Somebody else should be able to help you soon!

Offline

#10 2007-03-15 12:42:26

axueer
New Member
Registered: 2007-03-15
Posts: 7

Re: Sort order using a custom date field?

I can’t download the “cbs_category_list” plugins.I don’t know why….

Can you give me a URL to download?

If you have, you can give me use MSN,thank you!

Last edited by axueer (2007-03-15 12:43:54)

Offline

#11 2007-03-15 12:50:37

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: Sort order using a custom date field?

axueer, download link for cbs_category_list

Qwest, you could try using <txp:if_different /> to highlight the first event:

<txp:if_different><span class="highlight"></txp:if_different>
  <txp:title /> and other event info
<txp:if_different></span></txp:if_different>

Offline

#12 2007-03-15 13:06:49

axueer
New Member
Registered: 2007-03-15
Posts: 7

Re: Sort order using a custom date field?

rund ,thank you very much!

I download the “cbs_navigation_menu” plugin too.
Used the URL:http://users.edpnet.be/cbeyls/digitalia/files/cbs_navigation_menu.zip

Can you ask me this question?
http://forum.textpattern.com/viewtopic.php?id=21649

Offline

#13 2007-03-15 16:40:27

Qwest
Member
From: London, UK
Registered: 2007-01-24
Posts: 112

Re: Sort order using a custom date field?

ruud… Slight problem!

I started adding more dates earlier today, but it’s not sorting it correctly.. For example, there’s an event on the 21st April, and one on the 13 May. 13 May will appear sooner.

Any idea how to sort the problem out?! Or do you know of a plug in that might help!?..

Offline

#14 2007-03-15 18:25:53

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: Sort order using a custom date field?

If you want to order by date, you’d have to write dates like: 2007-04-21
For display purposes, you can convert that to a more pleasant looking date, using some PHP: <txp:php>echo strftime('%B %d, %G', strtotime(custom_field(array('name'=>'custom1 label'))));</txp:php>

Last edited by ruud (2007-03-16 10:45:49)

Offline

#15 2007-03-16 09:09:39

Qwest
Member
From: London, UK
Registered: 2007-01-24
Posts: 112

Re: Sort order using a custom date field?

ruud, that was what i was thinking! I didnt realise you could convert the date format via php!. I was thinking of using 2 custom fields, one entered as 2007-04-21 and then other as 21st Apr 07. The first custom field is for sorting, and the second is for display.

Will that php you’ve quoted work? Where do i put it?

Cheers :)

Offline

Board footer

Powered by FluxBB