Home : Products : Gossamer Links : Development, Plugins and Globals :

Products: Gossamer Links: Development, Plugins and Globals: Re: [Robert] Newest Links with all subcats?: Edit Log

Here is the list of edits for this post
Re: [Robert] Newest Links with all subcats?
I want to play soccer in twenty minutes, so i have not tested the global now

Code:
sub {

my ($output,$bild,$lcats);


my $all_db = $DB->table('Links');

$all_db->select_options ("ORDER BY Mod_Date DESC", "LIMIT 6");
my $sth = $all_db->select ( ['ID','URL','Title','Description','Add_Date'],
GT::SQL::Condition->new ('isValidated','=','Yes'

) );
while (my ($id,$title,$url,$descr,$adate) = $sth->fetchrow_array) {

my $links_db = $DB->table('Links');
my $fh = $links_db->file_info( 'b1', $id );
my $location = $fh->File_RelativePath;
if ($fh->File_Name =~ /\.(jpg|gif)$/) {
$bild="<img src='/aa/b1$location' title=\"$title $id\" alt=\"$title $id\">";
}


$cat_db->select_options ("ORDER BY Name", "");
my $sth = $cat_db->select( ['CategoryID','Name','Pfad'], { LinkID => $id } ) || die $GT::SQL::error;
my @cats;
while (my ($cid,$name,$pfad) = $sth->fetchrow_array) {

$lcats .= "| <a href=\"$pfad\">$name</a> ";
}

get_rid_of_the_first "| " !

$output .= "$bild <br> $title <br>$lcats ";

}
utf8::encode($output);
return $output;
}



It takes the newest ten links for the homepage, fetches a picture and all subcats sorted by name.

The result is eomething like

PICTURE
Title
cat1, cat, ... catn,

Instead of using Full_Name, i use Pfad = Path; (for different languages i have different pathes, but not here in the code)

Last edited by:

Robert: Sep 4, 2016, 12:59 AM

Edit Log: