Gossamer Forum
Home : Products : Links 2.0 : Customization :

Editor's PicK: Need to sort links purely on date

Quote Reply
Editor's PicK: Need to sort links purely on date
HELP!

I have hacked Links to death to use it as a magazine @ www.Ten-Tenths.com/Parc_Ferme/ and on the main page I use the editor's pick mod from this forum to create the list of main stories.

However, i'd like to have this list sorted purely on the date which it was added to the database (last addition at top) as i've already managed with the category pages (author pages in this use) eg www.Ten-Tenths.com/Parc_Ferme/Julie_Gates/

Any ideas ?

------------------
Craig Antill
10 Tenths Motorsport - www.Ten-Tenths.com/links/
Parc Ferme Magazine - www.Ten-Tenths.com/Parc_Ferme/
THE Directory - www.gardenbuildings.com/

Quote Reply
Re: Editor's PicK: Need to sort links purely on date In reply to
BTW, so as not to confuse you, the top two stories on that list are 'hard coded' into the page, so will not fit in with the 'by author' sort which follows....

Cheers!

------------------
Craig Antill
10 Tenths Motorsport - www.Ten-Tenths.com/links/
Parc Ferme Magazine - www.Ten-Tenths.com/Parc_Ferme/
THE Directory - www.gardenbuildings.com/

Quote Reply
Re: Editor's PicK: Need to sort links purely on date In reply to
Couldn't you just copy your old sort subroutine in db_utils.pl, then give it a new name, make it sort only by date, then make that mod sort by that subroutine by changing the one it points to.

------------------
------------------------------------------
Lavon Russell
LookHard! Search
http://www.lh.yi.org
webmaster@lh.yi.org
Quote Reply
Re: Editor's PicK: Need to sort links purely on date In reply to
To be honest, I haven't a clue how this works! I suspect that if I was to change this routine in some way it would be it:

Code:
sub build_pick_page {
# --------------------------------------------------------
# Creates a "Editor's Pick" page.
local ($total, $link_results, $title_linked);
my (%link_output, $category_clean);
if ($build_pick_path =~ m,^$build_root_path/(.*)$,) {
&build_dir ($1);
}
$total = 0;
CATEGORY: foreach $category (sort keys %pick_links) {
LINK: for ($i = 0; $i < ($#{$pick_links{$category}}+1) / ($#db_cols + 1); $i++) {
$total++;
%tmp = &array_to_hash ($i, @{$pick_links{$category}});
$link_output{$category} .= &site_html_link (%tmp) . "\n";
}
}
foreach $category (sort keys %pick_links) {
$category_clean = &build_clean ($category);
# $link_results .= qq|<P><A HREF="$build_root_url/$category/$build_index">$category_clean</A>\n|;
$link_results .= $link_output{$category};
}
$title_linked = &build_linked_title ("Picks");
open (PICK, ">$build_pick_path/$build_index") or cgierr ("unable to open editor's picks page: $build_pick_path/$build_index. Reason: $!");
print "\tEditor's Picks: $total\n";
print PICK &site_html_pick(@pick_links);
close PICK;
}

Thanks for any help

------------------
Craig Antill
10 Tenths Motorsport - www.Ten-Tenths.com/links/
Parc Ferme Magazine - www.Ten-Tenths.com/Parc_Ferme/
THE Directory - www.gardenbuildings.com/

Quote Reply
Re: Editor's PicK: Need to sort links purely on date In reply to
Are there any other variables you had to set up for this mod, if so what were they?

------------------
------------------------------------------
Lavon Russell
LookHard! Search
http://www.lh.yi.org
webmaster@lh.yi.org
Quote Reply
Re: Editor's PicK: Need to sort links purely on date In reply to
See this topic for full details: http://www.gossamer-threads.com/scripts/forum/resources/Forum3/HTML/000903.html

------------------
Craig Antill
10 Tenths Motorsport - www.Ten-Tenths.com/links/
Parc Ferme Magazine - www.Ten-Tenths.com/Parc_Ferme/
THE Directory - www.gardenbuildings.com/

Quote Reply
Re: Editor's PicK: Need to sort links purely on date In reply to
Craig Anthill
See if this helps:

Open your link.def file and go to this section:

# Field number to sort links by:
$db_sort_links = 1;

And change 1 to the number of the field you want to sort by.

Which is found in this section:


# Definition of your database file.
%db_def = (
ID => [0, 'numer', 5, 8, 1, '', ''],
Title => [1, 'alpha', 40, 75, 1, '', ''],
URL => [2, 'alpha', 40, 75, 1, 'http://', '^http|news|mailto|ftp'],
modified => [3, 'date', 15, 15, 1, \&get_date, ''],
Category => [4, 'alpha', 0, 150, 1, '', ''],
Description => [5, 'alpha', '40x3', 500, 0, '', ''],
'Contact Name' => [6, 'alpha', 40, 75, 1, '', ''],
'Contact Email' => [7, 'alpha', 40, 75, 1, '', '.+@.+\..+'],
Password => [20, 'alpha', 10, 10, 1, '', ''],
Price => [15, 'alpha', 20, 10, 1, '', ''],
Version => [16, 'alpha', 10, 10, 1, '', ''],
OS => [17, 'alpha', 10, 10, 1, '', ''],
Hits => [8, 'numer', 10, 10, 1, '0', '\d+'],
isNew => [9, 'alpha', 0, 5, 0, 'No', ''],
isPopular => [10, 'alpha', 0, 5, 0, 'No', ''],
Rating => [11, 'numer', 10, 10, 1, 0, '^[\d\.]+$'],
Votes => [12, 'numer', 10, 10, 1, 0, '^\d+$'],
ReceiveMail => [13, 'alpha', 10, 10, 1, 'Yes', 'No|Yes']
);


Does that help.

oops the modification field in this on may be the date field in yours which I beleive is the one you want his that so.


------------------
tassie
webmaster@scriptfarm.com
www.scriptfarm.com

[This message has been edited by tassie (edited August 08, 1999).]
Quote Reply
Re: Editor's PicK: Need to sort links purely on date In reply to
Sadly no Frown That works fine for the main sort (search, categories, etc.) but the editors pick, cool and new pages all use their own sort routines.

Thanks anyway!

------------------
Craig Antill
10 Tenths Motorsport - www.Ten-Tenths.com/links/
Parc Ferme Magazine - www.Ten-Tenths.com/Parc_Ferme/
THE Directory - www.gardenbuildings.com/

Quote Reply
Re: Editor's PicK: Need to sort links purely on date In reply to
craig Antill

I have just spent the last 20 minutes looking at hellraida Code and there is noway you can change the sort I mean there is but you would have to change virtual all His code and thats a bit beyond me at the moment.

Maybe ask widgetz although he is rather bussie at the moment.

Sorry.

------------------
tassie
webmaster@scriptfarm.com
www.scriptfarm.com
Quote Reply
Re: Editor's PicK: Need to sort links purely on date In reply to
hi Smile

i need the code that gets the hash

pick_links

thanks

jerry
Quote Reply
Re: Editor's PicK: Need to sort links purely on date In reply to
Thanks tassie.

widgetz, what do you need to know ? I've posted sub build_pick_page above if that helps...

------------------
Craig Antill
10 Tenths Motorsport - www.Ten-Tenths.com/links/
Parc Ferme Magazine - www.Ten-Tenths.com/Parc_Ferme/
THE Directory - www.gardenbuildings.com/

Quote Reply
Re: Editor's PicK: Need to sort links purely on date In reply to
i need to have the code for when it gets %pick_links

should be somewhere in build_stats or something
Quote Reply
Re: Editor's PicK: Need to sort links purely on date In reply to
Well, here's my sub build_stats FYI: Smile

Code:
sub build_stats {
# --------------------------------------------------------
# This routine does a lot of the messy work. It builds globally accessible
# arrays of new_links and cool_links. It finds out how many links are in each
# category, and whether a category contains a new/modified link.

my (@values, $category, $cat, @alt_categories, @categorylist, $depth, $i, $cat, %unique_categories);
my $staggered_mode = shift &#0124; &#0124; undef;

open (DB, "<$db_file_name") or &cgierr("unable to open database: $db_file_name. Reason: $!");
LINE: while (<DB> ) {
/^#/ and next LINE; # Skip comment Lines.
/^\s*$/ and next LINE; # Skip blank lines.
chomp;
@values = &split_decode ($_);
$category = $values[$db_category];

# Add the link to the list of links.
push (@{$links{$category}}, @values) if (!$staggered_mode);
$grand_total++;

# Add the link to the alternate categories as well.
if (defined $db_alt) {
@alt_categories = split(/\Q$db_delim\E/, $values[$db_alt]);
foreach (@alt_categories) {
push (@{$links{$_}}, @values);
}
}

# Add the link to the list of new links if it is new.
push (@{$new_links{$category}}, @values) if ($values[$db_isnew] eq "Yes");

# Add the link to the list of cool links if it is popular.
push (@{$cool_links{$category}}, @values) if ($values[$db_ispop] eq "Yes");

# Add the link to the list of pick links if it is popular.
push (@{$pick_links{$category}}, @values) if ($values[$db_ispick] eq "Yes");

# Add the link to the list of uk links if it is popular.
push (@{$uk_links{$category}}, @values) if ($values[$db_location] eq "UK Specific");

# This adds one to the total of each category above the current category.
# We have to caluclate the affect of the link on each alt category as well as the main.
%unique_categories = "";
foreach $cat ($category, @alt_categories) {

# Calculate the stats: the number of links and the newest link.
@categorylist = split (/\//, $cat);
$depth = $#categorylist;

# This adds one to the total of each category above the current category,
# and also marks any above categories new, if this link is new.
for $i (0 .. $depth) {
if (! defined ($unique_categories{$cat})) {
$unique_categories{$cat} += 1;
$stats{$cat}[0]++;
}
if ((!$stats{$cat}[1]) &#0124; &#0124; &compare_dates($values[$db_modified], $stats{$cat}[1])) {
$stats{$cat}[1] = $values[$db_modified];
}
pop (@categorylist);
$cat = join("/", @categorylist);
}
}
}
close DB;

# Now we have to sort the links and categories..
if (!$staggered_mode) {
foreach $link ( keys %links ) {
@{$links{$link}} = &build_sorthit (@{$links{$link}});
}
foreach $cat ( keys %subcategories ) {
@{$subcategories{$cat}} = sort @{$subcategories{$cat}};
}
}
$grand_total &#0124; &#0124;= 0;
}

Cheers!

------------------
Craig Antill
10 Tenths Motorsport - www.Ten-Tenths.com/links/
Parc Ferme Magazine - www.Ten-Tenths.com/Parc_Ferme/
THE Directory - www.gardenbuildings.com/

Quote Reply
Re: Editor's PicK: Need to sort links purely on date In reply to
this line...

Code:
push (@{$pick_links{$category}}, @values) if ($values[$db_ispick] eq "Yes");

change to:

Code:
push (@pick_links, @values) if ($values[$db_ispick] eq "Yes");

right before this..

Code:
$grand_total &#0124; &#0124;= 0;

add this

Code:
@pick_links = &build_sorthit (@pick_links);

then the sub...

change it to this

Code:
sub build_pick_page {
# --------------------------------------------------------
# Creates a "Editor's Pick" page.
local ($total, $link_results, $title_linked);

if ($build_pick_path =~ m,^$build_root_path/(.*)$,) {
&build_dir ($1);
}
$total = 0;

LINK: for ($i = 0; $i < ($#pick_links+1) / ($#db_cols + 1); $i++) {
$total++;
%tmp = &array_to_hash ($i, @pick_links);
$link_results .= &site_html_link (%tmp) . "\n";
}

$title_linked = &build_linked_title ("Picks");
open (PICK, ">$build_pick_path/$build_index") or cgierr ("unable to open editor's picks page: $build_pick_path/$build_index. Reason: $!");
print "\tEditor's Picks: $total\n";
print PICK &site_html_pick(@pick_links);
close PICK;
}

hope that helps you

(i haven't tested.. so tell me how it works)

jerry
Quote Reply
Re: Editor's PicK: Need to sort links purely on date In reply to
WOW!! Brilliant - works spot on first time - cheers! Smile Looks like my contributing authors can stop bickering now Smile

Thanks again!

------------------
Craig Antill
10 Tenths Motorsport - www.Ten-Tenths.com/links/
Parc Ferme Magazine - www.Ten-Tenths.com/Parc_Ferme/
THE Directory - www.gardenbuildings.com/

Quote Reply
Re: Editor's PicK: Need to sort links purely on date In reply to
i guess it has become easy after doing the category and search sorts.. Smile

jerry
Quote Reply
Re: Editor's PicK: Need to sort links purely on date In reply to
How to sort newest pick link on top?

Chai-Yo!
Quote Reply
Re: Editor's PicK: Need to sort links purely on date In reply to
Nevermind... found build_sorthit in db_utils.pl. Now, how to change
this to sort by pick_date field on Editor's Picks page... hmmm.


[This message has been edited by oldmoney (edited November 28, 1999).]
Quote Reply
Re: Editor's PicK: Need to sort links purely on date In reply to
Thanks for the codes, Widgetz....Working nicely with my Sites of the Month Award page.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
* Be sure to visit the Resource Center for FAQ's, Modifications and Extra Goodies!!
* Search Forums!
* Say NO to Duplicate Threads. :)
----------------------