Gossamer Forum
Home : Products : Links 2.0 : Customization :

Ordering the Links RECIP, COOL, NEW, ALPHA

Quote Reply
Ordering the Links RECIP, COOL, NEW, ALPHA
I recenlty installed the Reiprical link MOD sucessfully, but I was not able to give priority to the Recip links, I followed everything in the threads and resource center, but I still get the same problem, the new links always appear firstm then cool, then recip

Here is my code, maybe someone could tell me what is wrong with it

sub build_sorthit {
# --------------------------------------------------------
# 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, %isrecip, %isnew, %iscool, $hit, $i, @sorted);
for ($i = 0; $i < $num; $i++) {
$sortby{$i} = $unsorted[$db_sort_links + ($i * ($#db_cols+1))];
($unsorted[$db_isrecip + ($i * ($#db_cols+1))] eq "Yes") and ($isrecip{$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 {
($isrecip{$b} and !$isrecip{$a}) and return 1;
($isrecip{$a} and !$isrecip{$b}) and return -1;
($isnew{$b} and !$isnew{$a}) and return 1;
($isnew{$a} and !$isnew{$b}) and return -1;
($iscool{$b} and !$iscool{$a}) and return 1;
($iscool{$a} and !$iscool{$b}) and return -1;
($isrecip{$a} and $isrecip{$b}) and return lc($sortby {$a}) cmp lc($sortby{$b});
($isnew{$a} and $isnew{$b}) and return lc($sortby{$a}) cmp lc($sortby{$b});
($iscool{$a} and $iscool{$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;
}


Quote Reply
Re: Ordering the Links RECIP, COOL, NEW, ALPHA In reply to
Hey eliot, I've been looking all over in the threads and can't seem to find a solution to this problem. I can't get my links to order correctly. This is what i'm trying to get RECIP,NEW,COOL but nothing seems to work here is my subbuild clean routine
***********This is the exact same routine for the priority mod and I just switched priority to isrecip. I have no idea whats the problem and spend about 2 whole days trying to figure this little problem. I am in desperate need of help!


Quote Reply
Re: Ordering the Links RECIP, COOL, NEW, ALPHA In reply to
Search this forum for build sorthit new.

Regards,

Eliot Lee
Quote Reply
Re: Ordering the Links RECIP, COOL, NEW, ALPHA In reply to
I checked all over the forum and I still can't fix the problem, my sub sorhit is exactly how is says in the priority mod but it seems no matter what I change new links all always first, then the popular, I even switched all the $isnew to $iscool and it doesn't make any difference. Could it be another file that is wrong?

Quote Reply
Re: Ordering the Links RECIP, COOL, NEW, ALPHA In reply to
That code looks okay. Have you defined it properly in links.def:

Ie. is the field a Yes/No field called 'isRecip' and have you defined it further down as $db_isrecip

Good Luck!

Glenn


http://findarom.emusanet.com/comments3/
Quote Reply
Re: Ordering the Links RECIP, COOL, NEW, ALPHA In reply to
Yes I have defined everything and it seems no matter what I do, the order always stays the same. I even switched isNew with isRecip and everthing is still the same, so I'm assuming its not a problem with the db util

Let me show you my link.def file (I changed it to priority)
# -------------
# Links
# -------------
# Links Manager
#
# File: links.def
# Description: Contains the database definition for links.
# Author: Alex Krohn
# Email: alex@gossamer-threads.com
# Web: http://www.gossamer-threads.com/
# Version: 2.01
#
# (c) 1998 Gossamer Threads Inc.
#
# This script is not freeware! Please read the README for full details
# on registration and terms of use.
# =====================================================================

# Database Definition: LINKS
# --------------------------------------------------------
# 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'],
Date => [3, 'date', 15, 15, 1, \&get_date, ''],
Category => [4, 'alpha', 0, 150, 1, '', ''],
AltCategories => [5, 'alpha', 0, 500, 0, '', ''],
Description => [6, 'alpha', '40x3', 500, 0, '', ''],
'Contact Name' => [7, 'alpha', 40, 75, 1, '', ''],
'Contact Email' => [8, 'alpha', 40, 75, 1, '', '.+@.+\..+'],
Hits => [9, 'numer', 10, 10, 1, '0', '\d+'],
isNew => [10, 'alpha', 0, 5, 0, 'No', ''],
isPopular => [11, 'alpha', 0, 5, 0, 'No', ''],
Rating => [12, 'numer', 10, 10, 1, 0, '^[\d\.]+$'],
Votes => [13, 'numer', 10, 10, 1, 0, '^\d+$'],
ReceiveMail => [14, 'alpha', 10, 10, 1, 'Yes', 'No|Yes'],
recip => [15, 'alpha', 40, 75, 0, '', '^http|news|mailto|ftp'],
Priority => [16, 'alpha', 0, 5, 1, 'No', 'No|Yes']

);

# Database file to use -- defined in links.cfg.
$db_file_name = $db_links_name;
# Counter file to use -- defined in links.cfg.
$db_id_file_name = $db_links_id_file_name;
# The column name for the database key.
$db_key = 'ID';
# Database delimeter.
$db_delim = '|';
# Title used in admin output.
$html_title = 'Links Database';
$html_object = 'Link';

# Field Number of some important fields. The number is from %db_def above
# where the first field equals 0.
$db_alt = 5; $db_Priority = 16;
$db_category = 4; $db_modified = 3; $db_url = 2;
$db_hits = 9; $db_isnew = 10; $db_ispop = 11;
$db_contact_name = 7; $db_contact_email = 8; $db_title = 1;
$db_votes = 13; $db_rating = 12; $db_mail = 14;

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

# Field names you want to allow visitors to search on:
@search_fields = (1,5,2,4,6);

# System defaults. When adding new links or modifying links, these fields
# can not be overwritten by a user.
%add_system_fields = (
isNew => 'No',
isPopular => 'No',
Hits => '0',
Priority => 'No',
Rating => 0,
Votes => 0,
ReceiveMail => 'Yes'

);

# Hash of column names to possible options. If you want to use a select form
# field, you can use &build_select_field in your HTML page. This routine will
# make a <SELECT> input tag using the following values:
%db_select_fields = (
isNew => 'Yes,No',
isPopular => 'Yes,No',
ReceiveMail => 'Yes,No',
Priority => 'Yes,No'
);

# Hash of column names to radio values. If you use &build_radio_field, it will
# make a <INPUT TYPE="RADIO"> tag for you using the options specified in the hash.
%db_radio_fields = ( );

# Maximum number of hits returned in a search. Can be overridden in the search
# options.
$db_max_hits = 20;

# Use the built in key tracker.
$db_key_track = 1;

# ===========================================================================
# Build up some variables from your definitions. Internal use only.
@db_cols = ();
foreach (sort { $db_def{$a}[0] <=> $db_def{$b}[0] } keys %db_def) {
push (@db_cols, $_);
$db_sort{$_} = $db_def{$_}[1];
$db_form_len{$_} = $db_def{$_}[2];
$db_lengths{$_} = $db_def{$_}[3];
$db_not_null{$_} = $db_def{$_}[4];
$db_defaults{$_} = $db_def{$_}[5];
$db_valid_types{$_} = $db_def{$_}[6];
($_ eq $db_key) and $db_key_pos = $db_def{$_}[0];
}

1;
Is there anything wrong with it?



Quote Reply
Re: Ordering the Links RECIP, COOL, NEW, ALPHA In reply to
'Is there anything wrong with it?'

Yes! You need to add a new a Yes/No field called isRecip:

isRecip => [17, 'alpha', 10, 10, 1, 'Yes', 'No|Yes'],


and then you need to define it:

$db_isrecip = 17;

then in the db_select fields add

isRecip => 'Yes,No'


I noticed your using the priority mod. If so forget the above and instead just alter the sorthit sub in db_utilities.

Everytime you refer to 'isRecip' instead refer to 'Priority'


Good Luck!

Glenn


http://findarom.emusanet.com/comments3/
Quote Reply
Re: Ordering the Links RECIP, COOL, NEW, ALPHA In reply to
Thanks, but I already did everything, I've been rrunning isreci[ as priority and have everything defined already as you can see, but It still giver me a problem

Quote Reply
Re: Ordering the Links RECIP, COOL, NEW, ALPHA In reply to
If you mean everything is defined and correct in the code above......, then no it's not correct.

Look at the priority mod in the resource center and you'll notice that their build sorthit in db_utils.pl is different to yours!

Good Luck!

Glenn


http://findarom.emusanet.com/comments3/
Quote Reply
Re: Ordering the Links RECIP, COOL, NEW, ALPHA In reply to
sorry I printed the wrong thing heres my part of my db_utils and it still doesn't work
its exactly like the priority mod

sub build_sorthit {
# --------------------------------------------------------
# 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, %isnew, %iscool, $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))] eq "Yes") and ($priority{$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 {
($priority{$b} and !$priority{$a}) and return 1;
($priority{$a} and !$priority{$b}) and return -1;
($isnew{$b} and !$isnew{$a}) and return 1;
($isnew{$a} and !$isnew{$b}) and return -1;
($iscool{$b} and !$iscool{$a}) and return 1;
($iscool{$a} and !$iscool{$b}) and return -1;
($priority{$a} and $priority{$b}) and return lc($sortby{$a}) cmp lc($sortby{$b});
($isnew{$a} and $isnew{$b}) and return lc($sortby{$a}) cmp lc($sortby{$b});
($iscool{$a} and $iscool{$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;
}

I've tried everything I know, Maybe I should reinstall links all over again, but that means all the time I spend modifying wwould be for nothing. BTW Thanks Glenn for the help. Could there be anything else?

This is the only mod I've had real trouble with

Quote Reply
Re: Ordering the Links RECIP, COOL, NEW, ALPHA In reply to
Try the following: -

sub build_sorthit {
# --------------------------------------------------------
# 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, %isnew, %iscool, $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))] eq "Yes") and ($priority{$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 {
($priority{$b} and !$priority{$a}) and return 1;
($priority{$a} and !$priority{$b}) and return -1;
($isnew{$b} and !$isnew{$a} and !$priority{$a} and !$priority{$b}) and return 1;
($isnew{$a} and !$isnew{$b} and !$priority{$a} and !$priority{$b}) and return -1;
($iscool{$b} and !$iscool{$a} and !$priority{$a} and !$priority{$b}) and return 1;
($iscool{$a} and !$iscool{$b} and !$priority{$a} and !$priority{$b}) and return -1;
($priority{$a} and $priority{$b}) and return lc($sortby{$a}) cmp lc($sortby{$b});
($isnew{$a} and $isnew{$b}) and return lc($sortby{$a}) cmp lc($sortby{$b});
($iscool{$a} and $iscool{$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;
}


http://www.humorlinks.com
Quote Reply
Re: Ordering the Links RECIP, COOL, NEW, ALPHA In reply to
Thanks, but I tried it and it didn't work, I guest I'll try to install everthing form scratch again

Thanks : )

Travis