Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Detailed pag printing Links and Categories too?

(Page 2 of 2)
> >
Quote Reply
Re: [carminejg3] Detailed pag printing Links and Categories too? In reply to
sub {
my $tags = shift;
my ($cat_id, $cat_name) = each %{$DB->table('Links')->get_categories($tags->{ID})};
my $link_db = $DB->table('Links','CatLinks');
$link_db->select_options ("ORDER BY $CFG->{build_sort_order_category} LIMIT 5");
my $sth = $link_db->select ( { CategoryID => $cat_id });
my $output = '';
while (my $link = $sth->fetchrow_hashref) {
$output .= Links::SiteHTML::display('link', $link);
}
return $output;
}
Quote Reply
Re: [carminejg3] Detailed pag printing Links and Categories too? In reply to
I have updated this global to output as a loop to allow more flexibility in the display, added a check for isValidated and links plucked by random order.

The only problem is the link detailed page its on is also in the output - any programmer clever enough to exclude the current link please chip in!

Code:
-- Related

sub {
my (@links,$sth,$link);
my $tags = shift;
my ($cat_id, $cat_name) = each %{$DB->table('Links')->get_categories($tags->{ID})};
my $link_db = $DB->table('Links','CatLinks');
$link_db->select_options ("ORDER BY RAND()","LIMIT 5");
my $sth = $link_db->select ( { CategoryID => $cat_id }, {isValidated => 'Yes'});
while (my $link = $sth->fetchrow_hashref) {
$link = Links::SiteHTML::tags('link', $link);
push@links, $link;
}
return {relate=>\@links};
}


<%Related%>
<%loop relate%>
<a href="<%detailed_url%>"><%Title%></a><br />
<%endloop%>

~ ERASER


Free JavaScripts @ Insight Eye
Quote Reply
Re: [Eraser] Detailed pag printing Links and Categories too? In reply to
unless ($link->{ID} == $tags->{ID}){
push@links, $link;
}
Quote Reply
Re: [carminejg3] Detailed pag printing Links and Categories too? In reply to
How do I make the links show randomly each time the page is refreshed/visited using the code:


sub {
my $tags = shift;
my ($cat_id, $cat_name) = each %{$DB->table('Links')->get_categories($tags->{ID})};
my $link_db = $DB->table('Links','CatLinks');
$link_db->select_options("ORDER BY RAND()","LIMIT 5");
my $sth = $link_db->select({ CategoryID => $cat_id });
my $output = '';
while (my $link = $sth->fetchrow_hashref) {
$output .= Links::SiteHTML::display('link', $link);
}
return $output;
}


The select_options above displays random links but I want the list to change each time the detailed page is visited/refreshed, showing another set of random links from the particular category.

Please help. Thanks



Quote Reply
Re: [Bruha] Detailed pag printing Links and Categories too? In reply to
ok i have managed to make this work
Just in case others are interested here's the code I use :

sub {
my $tags = shift;
my ($cat_id, $cat_name) = each %{$DB->table('Links')->get_categories($tags->{ID})};
my $link_db = $DB->table('Links','CatLinks');
$link_db->select_options("ORDER BY RAND()","LIMIT 5");
my $sth = $link_db->select({ CategoryID => $cat_id });
my $output = '';
while (my $link = $sth->fetchrow_hashref) {

$link->{Description};
push (@output, $link);
}
return $output;
}
Quote Reply
Re: [carminejg3] Detailed pag printing Links and Categories too? In reply to
10 years later:

$link_db->select_options ("ORDER BY $CFG->{build_sort_order_category}","LIMIT 5");


Laugh

> >