Gossamer Forum
Home : Products : Links 2.0 : Customization :

Step By Step

Quote Reply
Step By Step
Ok I want to know how to make priority links using Links 2.0. I have read through some things here and e-mailed one or two people who have never responded and was wondering if someon can walk me through here step by step how to set this up.

God Bless,

Jason
Quote Reply
Re: [LordStryfe] Step By Step In reply to
Do you want to be able to 'rank' your links? Choose the order they appear? Use the Priority Logo Mod, skip the logo part. It's in the Resource Section. The instructions are well-written, should be no problem.


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] Step By Step In reply to
I want to chose which ones are at the top. I couldn't find that mod you talked about.
Quote Reply
Re: [LordStryfe] Step By Step In reply to
I see the mos no longer there, and the address I have for it gives a 404. But, you can do what you want with this:

http://www.gossamer-threads.com/...ated%20number;#41304


Leonard
aka PerlFlunkie
Quote Reply
Re: [LordStryfe] Step By Step In reply to
Anyone going to be online on a messenger to help someone?
Quote Reply
Re: [LordStryfe] Step By Step In reply to
add a field called priority to your links.def file. I set mine to ALPHA with length of 3. Then assign a value to every link in the link.db file using all three places such as 005 or 050 or 500. Higher "numbers" will be listed at the top.

also in links.def set the variable $db_sort_links equal to the field number of the priority field.

and add the $db_priority to the "Field Number of some important fields."

then in db_utils.pl rename the build_sorthit function to build_sorthit_old

insert the following just before the old one:

Code:
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;
}


or i think the following aslo works.

Code:
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, %isPriority, $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);
} foreach $hit (sort {
($isPriority{$b} and !$isPriority{$a}) and return 1;
($isPriority{$a} and !$isPriority{$b}) and return -1;
($isPriority{$a} and $isPriority{$b}) and return $Priority{$a} cmp $Priority{$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;
}


Gene
"The older I get, the more I admire competence, just simple competence in any field from adultery to zoology."
Quote Reply
Re: [esm] Step By Step In reply to
Ok lets take this a set at a time. You said add a field in the links.def file what will this field look like?

Last edited by:

LordStryfe: Jul 14, 2003, 12:00 PM
Quote Reply
Re: [LordStryfe] Step By Step In reply to
Code:
Priority => [17, 'alpha', 3, 3, 0, '001', '']


Change 17 so that it is the next sequential number in the %db_def section of your links.def file.

Assuming this is the last field, make sure the preceding line ends with a comma...






Gene
"The older I get, the more I admire competence, just simple competence in any field from adultery to zoology."
Quote Reply
Re: [esm] Step By Step In reply to
ok what file does this go in and what where in it does it go?
Quote Reply
Re: [LordStryfe] Step By Step In reply to
In Reply To:
ok what file does this go in and what where in it does it go?


Code:


Change 17 so that it is the next sequential number in the %db_def section of your links.def file.


Gene
"The older I get, the more I admire competence, just simple competence in any field from adultery to zoology."
Quote Reply
Re: [LordStryfe] Step By Step In reply to
also see http://www.gossamer-threads.com/...;;page=unread#unread


Gene
"The older I get, the more I admire competence, just simple competence in any field from adultery to zoology."
Quote Reply
Re: [esm] Step By Step In reply to
Ok that is in what next.
Quote Reply
Re: [LordStryfe] Step By Step In reply to
further down see

Code:
# Field Number of some important fields. The number is from %db_def above
# where the first field equals 0.


add the following

Code:
$db_priority = 17;


where 17 is the same number you used above.

even further down see

Code:
# System defaults. When adding new links or modifying links,
these fields # can not be overwritten by a user. %add_system_fields = (


add the following

Code:
Priority => '0',


Note the comma. if it is the last item in the list, remove the comma.

Code:
%add_system_fields = (
isNew => 'No',
isPopular => 'No',
Hits => '0',
Priority => '001',
Rating => 0,
Votes => 0,
ReceiveMail => 'Yes',
);


the 001 is whatever default value you want to assign.


Gene
"The older I get, the more I admire competence, just simple competence in any field from adultery to zoology."
Quote Reply
Re: [esm] Step By Step In reply to
ok all of that is taken care of. What next?
Quote Reply
Re: [LordStryfe] Step By Step In reply to
next, you have to add a field delimiter to the end of each record of the database. This assumes the Priority field definition you created in the first step is the last field definition in the %db_def section of the links.def file. You will need to add a | at the end of each line of the links.db file.

There are several ways to do this. You could search this forum for a hack that does it for you. I have never used it so I don't know anything about it. But is has been recommended on several ocassions. I guess search for "add fields."

In any event, you should download the links.db file to your local hard drive.It wouldn't hurt to have 2 or 3 extra copies around.

Or you do it manually. Open the links.db file in your text editor and go at it. Some text editors let you create macros that simplify the process. see http://www.fixedsys.com/context/

Or use the program at http://home.hccnet.nl/...oftware/software.htm to add the field.

upload the new file if needed and chmod it to 666.


Gene
"The older I get, the more I admire competence, just simple competence in any field from adultery to zoology."
Quote Reply
Re: [esm] Step By Step In reply to
Ok once this is done then will the higher rates ones be at 001, 000 or something higher or what?
Quote Reply
Re: [LordStryfe] Step By Step In reply to
they will be blank. only the new one will show the new default values

if you edit the links.db by hand, you could add a value for each link. something like

Code:
|014
|035
|044
|007


or you could add using the csvdb program

Otherwise, you will have to use the modify function in the control panel to change the value.

the next step will be to add the new sort function...


Gene
"The older I get, the more I admire competence, just simple competence in any field from adultery to zoology."
Quote Reply
Re: [esm] Step By Step In reply to
What do you mean add a new sort feature? Is 001 higher priority then 002?
Quote Reply
Re: [LordStryfe] Step By Step In reply to
    
hmmmm....I said function, not feature.

Take a look at my first post. Specifically,

Code:
sub build_sorthit {



"sub" stands for sub-routine. I guess we would call it the "build_sorthit function" or "build_sorthit sub-routine."

So, how did the previous step go?

I think we have just one more step to go.

ps: the 001 and the 002 are just the values of the priority field. Most any field can be sorted on. The sort function will sort the field based on the values in the field. The sort function has an attribute that allows it to sort the data in either ascending or descending sequence. The value 001 is higher or lower than 002 only in relationship to this attribute. Think of it as objects in space. There is no up or down for them except in relationship to say the Earth or the moon.


Gene
"The older I get, the more I admire competence, just simple competence in any field from adultery to zoology."
Quote Reply
Re: [LordStryfe] Step By Step In reply to
Hello all. I'm a true novice at this.

All this stuff above will allow one to put, say, a particular advertiser's link and description at the top of a particular category or is the above a "GLOBAL" placement throughout ALL Of the categories?? Crazy Man, I'm confused but will continue searching other threads in hopes that I'll find something easier - if it exists. Thanks!