I'm running my head against the wall on this one. I have a collection of nodes which has two dropdowns for selecting a time: hour and minute. When rendering my nodes, I need to sort them based on this selection. Thing is, that the hours can start with a leading zero, i.e.: 02:15, 04:05 etc.
Of course, it sorts it the way it should. It's just that the time is loosely coupled (in fact, not coupled at all) to a certain date (it's a festival site), so the admin is basically able to pick whatever time he wants on a "day". I'll have to give them the ability to drag 'n drop-sorting on my datatype then :-) Seems to be the only way to get around this.
The "problem" is, that a day on a festival isn't nessecary from 00.00 to 00.00 as an artist can perform on "Wedensday 01.30" thus no particular date involved here.
It's quite ambigous :-D and the only real way to sort them is on the datatype.
Oh - I was wondering whether it was something like that :-)
Well, wouldn't you be able to automatically "assign" all times from, say, 00:00 to 07:59 or so (actually — musicians don't even wake up before noon, anyway, right? :-), to "belong" to the following date, sorting-wise, thus making them sort correct?
I'm just thinking it's a pain to implement drag 'n drop sorting for something that an editor would almost expect to sort by itself...
As long as there's a clear description for the editor, I'd say that could work... e.g. something like "Days go from 08:00 to 05:00 the following night".
I hear what you're saying about assigning all times to a date (and yes, musicians are lazy chaps! ;-)) Thing is, they want it to be as "open", flexible and loosely coupled as possible when making the program. Got a screenshot for you of my structure and datatype (don't mind the design of it though, it's not done yet :-D):
Having it like this, they are completely free to make the program, like they want, without limitations. Sorting it, however, is quite a challenge :-) But I think you are right, they would expect it to be auto-sorted when output on the page, so I have to figure out a way to do that.
If anyone got an idea of how to sort this, please let me know ;-)
Sorting by time (hours:minutes)
Hi all,
I'm running my head against the wall on this one. I have a collection of nodes which has two dropdowns for selecting a time: hour and minute. When rendering my nodes, I need to sort them based on this selection. Thing is, that the hours can start with a leading zero, i.e.: 02:15, 04:05 etc.
I've tried the following:
Which outputs my selection like this:
Is there any way to achieve this in XSLT, or do I have to clean my hands and write an extension to do it? ;-)
Any hint on this is greatly appreciated!
Thanks in advance.
- Bo
Hi Bo,
Sort them as text like this:
xsl:sort select="concat(Hours, Minutes)"
(Posting from mobile, taking no chances with code :-)
/Chriztian
Hi Chriztian,
Thanks for your input and fast reply :-)
I've tried to sort it like you wrote, but it gives me this output:
and with order="descending" it gives me this:
I think it's fairly logic that it sorts it like this, but it's the leading zero that causes the trouble. At least to my understanding :-)
Thanks again!
- Bo
Ok, I don't think I understand what you want as output then?
Are they not sorted correct? (Assuming all times are on same date)
/Chriztian
Oh hell.. I think it's getting late ;-)
Of course, it sorts it the way it should. It's just that the time is loosely coupled (in fact, not coupled at all) to a certain date (it's a festival site), so the admin is basically able to pick whatever time he wants on a "day". I'll have to give them the ability to drag 'n drop-sorting on my datatype then :-) Seems to be the only way to get around this.
The "problem" is, that a day on a festival isn't nessecary from 00.00 to 00.00 as an artist can perform on "Wedensday 01.30" thus no particular date involved here.
It's quite ambigous :-D and the only real way to sort them is on the datatype.
Thanks again!
- Bo
Oh - I was wondering whether it was something like that :-)
Well, wouldn't you be able to automatically "assign" all times from, say, 00:00 to 07:59 or so (actually — musicians don't even wake up before noon, anyway, right? :-), to "belong" to the following date, sorting-wise, thus making them sort correct?
I'm just thinking it's a pain to implement drag 'n drop sorting for something that an editor would almost expect to sort by itself...
As long as there's a clear description for the editor, I'd say that could work... e.g. something like "Days go from 08:00 to 05:00 the following night".
Anyways, was just thinking out loud :-)
/Chriztian
Hi Chriztian,
I hear what you're saying about assigning all times to a date (and yes, musicians are lazy chaps! ;-)) Thing is, they want it to be as "open", flexible and loosely coupled as possible when making the program. Got a screenshot for you of my structure and datatype (don't mind the design of it though, it's not done yet :-D):
Having it like this, they are completely free to make the program, like they want, without limitations. Sorting it, however, is quite a challenge :-) But I think you are right, they would expect it to be auto-sorted when output on the page, so I have to figure out a way to do that.
If anyone got an idea of how to sort this, please let me know ;-)
Thanks again!
- Bo
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.