Gossamer Forum
Home : Products : Links 2.0 : Customization :

priority links mod

Quote Reply
priority links mod
Hello, I searched the forum and need something that will allow me to make designated links show up at the tops of their respective categories. A mod called Priority Links seems to be just what I need. However, it's not in the resource section and all forum links to it seem to be 404s. Can anyone tell me where to find it, or post the code here?



Thanks
Quote Reply
Re: [allthingsfree] priority links mod In reply to
Use this thread

http://www.gossamer-threads.com/...cgi?post=41304#41304

and the mod attached. If the author of the mod does not want it posted, sorry for the trouble, I'm sure it can be removed. It's sad to know many of the great mods are so hard to find...


Leonard
aka PerlFlunkie
Quote Reply
Re: [allthingsfree] priority links mod In reply to
In Reply To:
Hello, I searched the forum and need something that will allow me to make designated links show up at the tops of their respective categories. A mod called Priority Links seems to be just what I need. However, it's not in the resource section and all forum links to it seem to be 404s. Can anyone tell me where to find it, or post the code here?



Thanks


I just went a little simpler. You could make Priorirty numeric is you want. Just change the values assigned to it. I assigned a default value of 005 just in case someone ticked me off in which case they got '000' Sly

Priority => [17, 'alpha', 3, 3, 0, '005', ''],

-------------------------------------------------------

$db_priority = 17;

-------------------------------------------------------

Priority => '005',

-------------------------------------------------------

sub build_sorthit {
# just priority
my (@unsorted) = @_;
my ($num) = ($#unsorted+1) / ($#db_cols+1);
my (%sortby, $hit, $i, @sorted, $column, $type);
for ($i = 0; $i < $num; $i++) {
$sortby{$i} = $unsorted[$db_sort_links + ($i * ($#db_cols+1))];
}
foreach $hit ( sort {
$sortby{$b} cmp $sortby{$a};
} (keys %sortby)) {
$first = ($hit * $#db_cols) + $hit;
$last = ($hit * $#db_cols) + $#db_cols + $hit;
push (@sorted, @unsorted[$first .. $last]);
}
return @sorted;
}


Gene
"The older I get, the more I admire competence, just simple competence in any field from adultery to zoology."
Quote Reply
Re: [esm] priority links mod In reply to
esm: Thanks, that appears to be just what I need. Can you explain the sort routine a little bit better? I am hoping to be able to sort on these three criteria in this order:

1. new
2. priority
3. rating

Thanks, Ryan
Quote Reply
Re: [allthingsfree] priority links mod In reply to
here are some sort_hit routines. The ones with "good" in the name actually worked. I'm not sure if they all work or not.

You will need to be careful about the type ( alpha or numeric ) you use with Priority. If you set Priority as alpha, you need to use the string operators (eq, ne, lt, gt, cmp, etc). If you set Priority as numeric, you need to use the numeric operators (==, !=, <, >, etc).

I never was very good with Perl, which I why I have switched to a completely PHP-based/mySQL system...

Code:
sub build_sorthity {
# --------------------------------------------------------
# This function sorts a list of links. It has been modified to sort
# new links first, then cool links, then the rest alphabetically. By modifying
# the sort function below, you can sort the links however you like (by date,
# or random, etc.).
#
my (@unsorted) = @_;
my ($num) = ($#unsorted+1) / ($#db_cols+1);
my (%sortby, %priority, %ispick, $hit, $i, @sorted); for ($i = 0; $i < $num; $i++) {
$sortby{$i} = $unsorted[$db_sort_links + ($i * ($#db_cols+1))];
$priority{$i} = $unsorted[$db_priority + ($i * ($#db_cols+1))];
($unsorted[$db_ispick + ($i * ($#db_cols+1))] eq "Yes") and ($ispick{$i} = 1);
}
foreach $hit (sort {
($priority{$b} and !$priority{$a}) and return 1;
($priority{$a} and !$priority{$b}) and return -1;
($ispick{$b} and !$ispick{$a}) and return 1;
($ispick{$a} and !$ispick{$b}) and return -1;
($priority{$a} and $priority{$b}) and return lc($sortby{$a}) cmp lc($sortby{$b});
($ispick{$a} and $ispick{$b}) and return lc($sortby{$a}) cmp lc($sortby{$b});
return lc($sortby{$a}) cmp lc($sortby{$b});
} (keys %sortby)) {
$first = ($hit * $#db_cols) + $hit;
$last = ($hit * $#db_cols) + $#db_cols + $hit;
push (@sorted, @unsorted[$first .. $last]);
}
return @sorted;
}



sub build_sorthitgoodaa {
# --------------------------------------------------------
# This function sorts a list of links. It has been modified to sort
# new links first, then cool links, then the rest alphabetically. By modifying
# the sort function below, you can sort the links however you like (by date,
# or random, etc.).
#
my (@unsorted) = @_;
my ($num) = ($#unsorted+1) / ($#db_cols+1);
my (%sortby, %priority, %ispriority, %ispick, %ispaid, $hit, $i, @sorted);



for ($i = 0; $i < $num; $i++) {
$sortby{$i} = $unsorted[$db_sort_links + ($i * ($#db_cols+1))];
($unsorted[$db_priority + ($i * ($#db_cols+1))]) and ($priority{$i} = 1);
($unsorted[$db_isPriority + ($i * ($#db_cols+1))] eq "Yes") and ($ispriority{$i} = 1);
($unsorted[$db_isPick + ($i * ($#db_cols+1))] eq "Yes") and ($ispick{$i} = 1);
($unsorted[$db_isPaid + ($i * ($#db_cols+1))] eq "Yes") and ($ispaid{$i} = 1);
}
foreach $hit (sort {
($priority{$b} and !$priority{$a}) and return 1;
($priority{$a} and !$priority{$b}) and return -1;
($ispriority{$b} and !$ispriority{$a}) and return 1;
($ispriority{$a} and !$ispriority{$b}) and return -1;
($ispick{$b} and !$ispick{$a}) and return 1;
($ispick{$a} and !$ispick{$b}) and return -1;
($ispaid{$b} and !$ispaid{$a}) and return 1;
($ispaid{$a} and !$ispaid{$b}) and return -1;



($priority{$a} and $priority{$b}) and return lc($sortby{$b}) cmp lc($sortby{$a});
($ispriority{$a} and $ispriority{$b}) and return lc($sortby{$b}) cmp lc($sortby{$b});
($ispick{$a} and $ispick{$b}) and return lc($sortby{$b}) cmp lc($sortby{$a});
($ispaid{$a} and $ispaid{$b}) and return lc($sortby{$b}) cmp lc($sortby{$a});



return lc($sortby{$a}) cmp lc($sortby{$b});
} (keys %sortby)) {
$first = ($hit * $#db_cols) + $hit;
$last = ($hit * $#db_cols) + $#db_cols + $hit;
push (@sorted, @unsorted[$first .. $last]);
}
return @sorted;
}





sub build_sorthit {
# just priority
my (@unsorted) = @_;
my ($num) = ($#unsorted+1) / ($#db_cols+1);
my (%sortby, $hit, $i, @sorted, $column, $type);
for ($i = 0; $i < $num; $i++) {
$sortby{$i} = $unsorted[$db_sort_links + ($i * ($#db_cols+1))];
}
foreach $hit ( sort {
$sortby{$b} cmp $sortby{$a};
} (keys %sortby)) {
$first = ($hit * $#db_cols) + $hit;
$last = ($hit * $#db_cols) + $#db_cols + $hit;
push (@sorted, @unsorted[$first .. $last]);
}
return @sorted;
}



sub build_sorthitr {
# just priority
my (@unsorted) = @_;
my ($num) = ($#unsorted+1) / ($#db_cols+1);
my (%sortby, $hit, $i, @sorted, $column, $type);
for ($i = 0; $i < $num; $i++) {
$sortby{$i} = $unsorted[$db_sort_links + ($i * ($#db_cols+1))];
}
foreach $hit (reverse sort {
$sortby{$b} cmp $sortby{$a};
} (keys %sortby)) {
$first = ($hit * $#db_cols) + $hit;
$last = ($hit * $#db_cols) + $#db_cols + $hit;
push (@sorted, @unsorted[$first .. $last]);
}
return @sorted;
}




sub build_sorthitgood {
# --------------------------------------------------------
# This function sorts a list of links. It has been modified to sort
# new links first, then cool links, then the rest alphabetically. By modifying
# the sort function below, you can sort the links however you like (by date,
# or random, etc.).
#
my (@unsorted) = @_;
my ($num) = ($#unsorted+1) / ($#db_cols+1);
my (%sortby, %Priority, %isPriority, %isPaid, %isPick, $hit, $i, @sorted);
for ($i = 0; $i < $num; $i++) {
$sortby{$i} = $unsorted[$db_sort_links + ($i * ($#db_cols+1))];
$Priority{$i} = $unsorted[$db_priority + ($i * ($#db_cols+1))];
($unsorted[$db_priority + ($i * ($#db_cols+1))] eq "Yes") and ($isPriority{$i} = 1);
($unsorted[$db_isPaid + ($i * ($#db_cols+1))] eq "Yes") and ($isPaid{$i} = 1);
($unsorted[$db_isPick + ($i * ($#db_cols+1))] eq "Yes") and ($isPick{$i} = 1);
}



foreach $hit (sort {
($isPriority{$b} and !$isPriority{$a}) and return 1;
($isPriority{$a} and !$isPriority{$b}) and return -1;
($isPaid{$b} and !$isPaid{$a} and !$isPriority{$a} and !$isPriority{$b}) and return 1;
($isPaid{$a} and !$isPaid{$b} and !$isPriority{$a} and !$isPriority{$b}) and return -1;
($isPick{$b} and !$isPick{$a} and !$isPriority{$a} and !$isPriority{$b}) and return 1;
($isPick{$a} and !$isPick{$b} and !$isPriority{$a} and !$isPriority{$b}) and return -1;
($isPriority{$a} and $isPriority{$b}) and return $Priority{$a} cmp $Priority{$b};
($isPaid{$a} and $isPaid{$b}) and return $sortby{$a} cmp $sortby{$b};
($isPick{$a} and $isPick{$b}) and return $sortby{$a} cmp $sortby{$b};
$sortby{$b} <=> $sortby{$a};
} (keys %sortby)) {
$first = ($hit * $#db_cols) + $hit;
$last = ($hit * $#db_cols) + $#db_cols + $hit;
push (@sorted, @unsorted[$first .. $last]);
}
return @sorted;
}




sub build_sorthitf {
# --------------------------------------------------------
# This function sorts a list of links. It has been modified to sort
# new links first, then cool links, then the rest alphabetically. By modifying
# the sort function below, you can sort the links however you like (by date,
# or random, etc.).
#
my (@unsorted) = @_;
my ($num) = ($#unsorted+1) / ($#db_cols+1);
my (%sortby, %Priority, %isPriority, %isPaid, %isPick, $hit, $i, @sorted);



for ($i = 0; $i < $num; $i++) {
$sortby{$i} = $unsorted[$db_sort_links + ($i * ($#db_cols+1))];
$Priority{$i} = $unsorted[$db_priority + ($i * ($#db_cols+1))];
($unsorted[$db_priority + ($i * ($#db_cols+1))] eq "Yes") and ($isPriority{$i} = 1);
($unsorted[$db_isnew + ($i * ($#db_cols+1))] eq "Yes") and ($isnew{$i} = 1);
($unsorted[$db_ispop + ($i * ($#db_cols+1))] eq "Yes") and ($iscool{$i} = 1);
}
foreach $hit (sort {
($isPriority{$a} and !$isPriority{$b}) and return -1;
($isPriority{$b} and !$isPriority{$a}) and return 1;
($isPaid{$b} and !$isPaid{$a} and !$isPriority{$a} and !$isPriority{$b}) and return 1;
($isPaid{$a} and !$isPaid{$b} and !$isPriority{$a} and !$isPriority{$b}) and return -1;
($isPick{$b} and !$isPick{$a} and !$isPriority{$a} and !$isPriority{$b}) and return 1;
($isPick{$a} and !$isPick{$b} and !$isPriority{$a} and !$isPriority{$b}) and return -1;
($isPriority{$a} and $isPriority{$b}) and return lc($Priority{$a}) cmp lc($Priority{$b});
($isPaid{$a} and $isPaid{$b}) and return lc($sortby{$a}) cmp lc($sortby{$b});
($isPick{$a} and $isPick{$b}) and return lc($sortby{$a}) cmp lc($sortby{$b});
return lc($sortby{$a}) cmp lc($sortby{$b});
} (keys %sortby)) {
$first = ($hit * $#db_cols) + $hit;
$last = ($hit * $#db_cols) + $#db_cols + $hit;
push (@sorted, @unsorted[$first .. $last]);
}
return @sorted;
}





sub build_sorthitx {
# --------------------------------------------------------
# This function sorts a list of links. It has been modified to sort
# new links first, then cool links, then the rest alphabetically. By modifying
# the sort function below, you can sort the links however you like (by date,
# or random, etc.).
#
my (@unsorted) = @_;
my ($num) = ($#unsorted+1) / ($#db_cols+1);
my (%sortby, %priority, $hit, $i, @sorted);
for ($i = 0; $i < $num; $i++) {
$sortby{$i} = $unsorted[$db_sort_links + ($i * ($#db_cols+1))];
$priority{$i} = $unsorted[$db_priority + ($i * ($#db_cols+1))];
($unsorted[$db_ispick + ($i * ($#db_cols+1))] eq "Yes") and ($ispick{$i} = 1);



}
foreach $hit (sort {
($priority{$b} and !$priority{$a}) and return 1;
($priority{$a} and !$priority{$b}) and return -1;
($ispick{$b} and !$ispick{$a}) and return 1;
($ispick{$a} and !$ispick{$b}) and return -1;
($priority{$a} and $priority{$b}) and return $priority{$b} <=> $priority{$a};
($ispick{$a} and $ispick{$b}) and return $sortby{$b} <=> $sortby{$a};
$sortby{$b} <=> $sortby{$a};
} (keys %sortby)) {
$first = ($hit * $#db_cols) + $hit;
$last = ($hit * $#db_cols) + $#db_cols + $hit;
push (@sorted, @unsorted[$first .. $last]);
}
return @sorted;
}


You now know more than I do!


Gene
"The older I get, the more I admire competence, just simple competence in any field from adultery to zoology."
Quote Reply
Re: [esm] priority links mod In reply to
Thanks for all the help! I have it working nicely now.
Quote Reply
Re: [allthingsfree] priority links mod In reply to
if you get a chance, post what you did.

Sorting gets a lot of questions.


Gene
"The older I get, the more I admire competence, just simple competence in any field from adultery to zoology."
Quote Reply
Re: [allthingsfree] priority links mod In reply to
I too am looking into adding or creating Priority Links for certain categories of my website. The priority links would only appear at the top of a few different categories.

All the above looks like it must be useful to someone... but not to someone who has no coding nor Perl knowledge or experience. I've had (and paid for) all my Perl programs to be "Professionally Installed". These "Professional Installs" are GREAT but not so great later when/if you need to modify something... like now!

I like the idea above of adding priority numbers but not sure how "it" knows to WHICH LINK you're adding priority.

I have the (what I suspect is the "DEFAULT") setting in place and all (ALMOST ALL) of the link titles are shown in alphabetical order. Fine. But not ALL of them are in alphabetical order and I don't know why.

For the potential client I've put a graphic in front of the client's link name which I inserted in "Links Database: Modify a Link" template just in front of their link name and that DID bump the client's link to the #3 link position in that category. That's great, but not good enough. I need it to be #1. There are two older links that seem to be cemented in the top two link spots in one particular category which I'd like to shove down to make room for this advertiser's link.

Any "professionals" out there looking to offer their "professional" (i.e. paid) services on this one? OR, should I write to the Gossamer Threads techies directly and ask them first? Thing is, I'd like an answer to this by tomorrow as I have a very highly prospective client who's willing to advertise if I can get his link+description in the top (#1) spot in the particularl category. HELP!! ĦĦSOCORRO!!

Last edited by:

MadridMan: Feb 26, 2004, 4:38 PM