Gossamer Forum
Home : Products : Links 2.0 : Customization :

Sort by designated number mod?

Quote Reply
Sort by designated number mod?
I am wondering how I can sort my links by designating each one a number. For example, when I add a link I want to be able to choose a number from zero to whatever and they will be listed top-down highest to lowest. I want to be able to choose any number as opposed to a 1-10 listing. Of course, listings will be able to share numbers. My page might look something like this: 23,17, 08, 08, 08, 06, 06, 04, 03, 00, 00.

Also, although I don't need this rating to be shown in the actual listing at this time, having the code to do so would be a bonus just in case it is needed at a later date.

I read several posts talking of something similiar which suggests using a mod of the Priority Logo mod but they didn't elaborate. Since my skills are limited was wondering if someone could lead me in the right direction.

The purpose of this mod (in case you haven't guessed) is so that I can display my highest paid links above my lower paid and then my non-paid links.

I would also want to disable the New and Pop sorting once installed.

We could call this mod "The Poor Man's GoTo" mod! Smile

Thanks and appreciate any help!
Quote Reply
Re: Sort by designated number mod? In reply to
I found this in one of the posts related to this subject:

"Use the priority logo modification, but rather than a "yes/no" field, make it a numerical field. Then, when picking out the priority links, SORT them based on the numeric field."

How does one "SORT them based on the numeric field"?

Thanks
Quote Reply
Re: Sort by designated number mod? In reply to
do you know how to add a new field?

just make one that is like this

Code:
Priority => [15, 'numer', 5, 8, 0, '0', '^\d+$']

then add

Code:
$db_priority = 15;

now don't forget to add the field to links.db (by using excel or update.pl)

change $db_sort_links (in links.def) to

Code:
$db_sort_links = $db_priority;

in %add_system_fields.. put what you want the DEFAULT value of the priority when a user adds it.. (i'd guess 0.. [bottom])

Code:
Priority => 0

then you need to change your BUILD_SORTHIT in DB_UTILS.pl..

to something like this

Code:
sub build_sorthit {
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} <=> $sortby{$a};
} (keys %sortby)) {
$first = ($hit * $#db_cols) + $hit;
$last = ($hit * $#db_cols) + $#db_cols + $hit;
push (@sorted, @unsorted[$first .. $last]);
}
return @sorted;
}

jerry
Quote Reply
Re: Sort by designated number mod? In reply to
Works like a charm! Thanks big time! Jerry, you the man!

[This message has been edited by Ted Monk (edited November 13, 1999).]
Quote Reply
Re: Sort by designated number mod? In reply to
Thanks for helping on this mod! Works great. So now I'd like to change the sort routine to the following:


1. Priority (which is already working)
2. Rating
3. Votes
4. Date

My build_sorthit currently looks like this:
Code:
sub build_sorthit {
#####
##modified on 991218 for priority numeric sort
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} <=> $sortby{$a};
} (keys %sortby)) {
$first = ($hit * $#db_cols) + $hit;
$last = ($hit * $#db_cols) + $#db_cols + $hit;
push (@sorted, @unsorted[$first .. $last]);
}
return @sorted;
}

Thanks for any help!

www.diamondtalk.com The Diamonds Discussion Forum.



[This message has been edited by joegilbert (edited February 26, 2000).]
Quote Reply
Re: Sort by designated number mod? In reply to
Anybody have ideas? This sort code is the only piece I don't quite get...Thanks!
Quote Reply
Re: Sort by designated number mod? In reply to
joegilbert

Have you added all the codes in the links.def file and the db_utils.pl file?

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: Sort by designated number mod? In reply to
Cool way to sort! You could have infinite levels. I assume that listings that share the same number are sorted alphabetically within that number. Would there be a way to sort randomly within each shared number?

Thanks.
Quote Reply
Re: Sort by designated number mod? In reply to
Hi Eliot/Anthrorules,

Thanks for the reply. I do have all the added fields working for awhile now, but I wanted to add more to the sort order. Widgetz code works fine. But the code he listed doesn't deal with the following in sorting:

2. Rating
3. Votes
4. Date

Actually, I'm thinking of adding a second priority field so that one of them is to create priority links and the other would be like a simple version of goto.com. Where people could do a one time payment to achieve a better listing, bidding against other listings. (Pay per click is an administrative nightmare) Anytime someone wants to go higher, they just bid more money, one shot. One credit card transaction.

Anyone who has used goto.com for awhile knows how long it took them to make their system any good, and it still has many flaws...

Anyways, so I guess that would make one new field, called priority2 (numerical) and the new sort order would be:

1. priority1
2. priority2
3. Rating
4. Votes
5. Date

I hope I was clear but my brain talks to myself faster and more clearly than my hands type so I'll explain better if you need me to...

cheers,
joe

P.S. Eliot, your site/mods rules!! I'm very impressed with your work. You also do mods @ UBB, right? Do you think it would be feasible for some people to get together and take the sql version of links and use the links database as the mysql version of ubb, while merging the databases. (easier said than done!) There is so much that could be done with one userid for both systems....supermods! This would satisfy a lot of people since the whole controversy surrounding OT.
Quote Reply
Re: Sort by designated number mod? In reply to
Thanks.

I have modded only a little bit of UBB. I am planning on a mod for a private mailer rather than listing everyone's email address...but I don't plan on releasing the code hack to the UBB forum, which I have found to be less user friendly than this one.

Anyway...Have you taken a look at the Priority Logo Mod in the Resource Center? This may shed some light in writing the Mod you are thinking of.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: Sort by designated number mod? In reply to
Hi Eliot,

Now I remember...I was confusing you with the gentleman running bartour...he did some great mods for ubb and you did some gr8 ones (as did widgetz) for links...

As for the priority mod, yes, I did install it a long time ago...and used the modification of making the priority field a numeric one so that you can really choose which link goes in order...I was just trying to refine the sort order. Sorry if I wasn't clear.

For the mailing hack, if you mean the private messages, it wasn't a bad idea but my users are having trouble with it...I'm waiting for the new release to fix the bugs..