Gossamer Forum
Home : Products : Links 2.0 : Discussions :

how to sort by date and time?

Quote Reply
how to sort by date and time?
well, i already read through http://gossamer-threads.com/perl/forum/showflat.pl?Cat=&Board=L2Cust&Number=25659&page=&view=&sb=&vc=1 . it works, my links are sorted by date. but i want to sort them by date and time, because if i add two links on the same day, the older one is shown above the newer one, so, what can i do?

Quote Reply
Re: how to sort by date and time? In reply to
Wouldn't they automatically sort, then, by time, since the whole string of get_date includes the time?

At any rate, to change the sort order for your database when you're using Links 2.0, open up your links.def file and edit it. Just make a backup before you do, in case your edits don't work out like you planned.

Do a search on the string

@search_fields =(

All you need to do is add, remove, or reorder the fields listed in between the brackets, and your sort order is changed.

_________________________________________
Support and Recovery Internet Yellow Pages
serving Canada, the US, the UK, and the World Wide Web
http://recovery.tlm.com

Quote Reply
Re: how to sort by date and time? In reply to
IYPWebmaster,

You are confusing subroutines and their functions.

sub get_date ONLY gets the CURRENT day-month-year and prints that in the Date field in the links.db and also is used with the date tag (<%date%>) for printing the build DATE.

There is a SUB called sub get_date_and_time (or something like this) in the links.cfg that prints a timestamp with the date and time included.

Now, yes, one could edit the get_date for the default value in the links.def file for the Date field definition and then use the get_date_and_time or whatever subroutine to print both date and time of link submissions.

But as Links 2.0 is currently written, it uses the get_date (which only GETS the DATE) for printing DATEstamps in the links.db and for printing NEW links in the NEW pages.

Regards,

Eliot Lee
Quote Reply
Re: how to sort by date and time? In reply to
Ah. Thanks for the heads'-up about the get_date_and_time subroutine. I hadn't looked for something like that, since I don't need that function, so I didn't know it was there. I also don't completely understand the various unix_to_date and date_to_unix subroutines, but since I don't need to adjust anything along those lines, I'll worry about figuring them out later, if ever.

After I hit the "submit" button, I thought that a field might need to be added in the links.def file, and maybe even a whole separate subroutine (get_time) added, to be able to sort by the time as well as by title and date.

__________________________________________
Support and Recovery Internet Yellow Pages
serving Canada, the US, the UK, and the World Wide Web
http://recovery.tlm.com

Quote Reply
Re: how to sort by date and time? In reply to
Not really...if you change the Date field to use sub get_date_and_time and then CONVERT all existing records to the correct format, then you would not have to add an additional field. You could if you wanted to, by simply adding Time and use &get_time as the default value.

Then edit the add.cgi and modify.cgi files to add the Time field properly.

Then edit the sub build_sorthit routine to sort by the TIME field in addition to the DATE field. Use DESCENDING codes to sort the TIME field.

Regards,

Eliot Lee
Quote Reply
Re: how to sort by date and time? In reply to
Hm, okay, I'll search that subroutine. If I succeed modding this, I will have to thank you a lot. If I don't, burn in hell, nay, just kidding ;).

Quote Reply
Re: how to sort by date and time? In reply to
While trying to sort by date and time 'using descending codes' I encountered one little problem. What ARE descending codes? ... Well, I'm not as good at Perl, so ... HELP! ... Thanks...

Quote Reply
Re: how to sort by alphabet In reply to
 
Sorry to go on a tangent here but I was going to post this as new but it must be linked to all this;

How do I ensure that all links are listed in alphabetical order in their catagories rather than by when they were entered, as they are now?

Thanks

Cakey

PS Yes I did a search first but it didn't throw anything up.

PPS answers in plain English rather than 'tech-speak' please