Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Improving Priority Mod

Quote Reply
Improving Priority Mod
While the regular priority mod is a great start, it's missing the ability to have a separate priority for each category. I started to ask how to make the improvement here: http://www.gossamer-threads.com/perl/forum/showflat.pl?Cat=&Board=LSQLNG&Number=142497&page=0&view=collapsed&sb=5

but I think I didn't explain properly what I did and made the thread too difficult to read. So let me start again.

The key table here is CatLinks. This table tells you exactly which Link belongs with which Category. SO, instead of adding a field called Priority in the Links table, if you do so in the CatLinks table, you can have a separate priority for each category.

So I created a new field in CatLinks (INT) called Priority. Now I need to do 2 things. One is to change the sort so that the first sort is on CatLinks.Priority DESC, which I think will work. The second thing is to create a global sub which will create a tag called <%Priority%> that will be viewable in the Links.html template.

Then of course it's just a matter of putting in <%Priority%> tag into the link.html template.

Alex suggested:
Code:
sub {
my $tags = shift;
my $link_id = $tags->{ID} or return;
my $catlnk_db = $DB->table('CatLinks');
my $sth = $catlnk_db->select ( { LinkID => $link_id } );
my $results = $sth->fetchrow_hashref;
...
return $output;
}
but I had to modify it and it didn't work. Here's what I modified it to:

Code:
sub {
my $tags = shift;
my $prio = $tags->{ID} or return;
my $catlnk_db = $DB->table('CatLinks');
my $sth = $catlnk_db->select ( { Priority => $prio } );
my $results = $sth->fetchrow_hashref;
$output=$results;
return $output;
}
Alex, or anybody, what did I do wrong?