Mar 8, 2004, 5:32 AM
Veteran / Moderator (18436 posts)
Mar 8, 2004, 5:32 AM
Post #2 of 21
Views: 6091
Not much help if you don't actually make a post
Cheers
Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!

Cheers
Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Mar 8, 2004, 6:47 AM
User (103 posts)
Mar 8, 2004, 6:47 AM
Post #3 of 21
Views: 6046
This is really curious as I did post something.
Any way here is it:
This global is great: it allows me to display on the front page the latest xx links. However, there is a problem when a link belongs to several categories: it appears duplicated. For example, if a link belongs to 3 categories, the global will diplay it 3 times.
So what should I add so no matter how much categories a links belongs to, it will be displayed only once ?
Thanks in advance,
Brakkar
# Displays the newest links on the home page.
my ($output,$sth,$link);
my $search_db = $DB->table('Links','CatLinks');
$search_db->select_options ('ORDER BY Add_Date DESC Limit 30');
my $cats = [35,42];
my $cond = GT::SQL::Condition->new( 'CategoryID','IN', $cats); $cond->not; my $cond2 = GT::SQL::Condition->new($cond, 'isValidated','=','Yes'); $sth = $search_db->select ( $cond2 ); my $x = 0; while ($link = $sth->fetchrow_hashref) {
$link->{'detailed_url'} = "$CFG->{build_detail_url}/$link->{'ID'}$CFG->{build_extension}";
Links::init_date();
$link->{Add_Date} = GT::Date::date_transform ($link->{Add_Date}, $CFG->{date_db_format}, $CFG->{date_user_format});
if ($x < 15) {
$output .= Links::SiteHTML::display('linkfront', $link);
}
else {
$output .= Links::SiteHTML::display('linkfront', $link);
}
$x++;
}
return $output;
}
Any way here is it:
This global is great: it allows me to display on the front page the latest xx links. However, there is a problem when a link belongs to several categories: it appears duplicated. For example, if a link belongs to 3 categories, the global will diplay it 3 times.
So what should I add so no matter how much categories a links belongs to, it will be displayed only once ?
Thanks in advance,
Brakkar
Quote:
sub { # Displays the newest links on the home page.
my ($output,$sth,$link);
my $search_db = $DB->table('Links','CatLinks');
$search_db->select_options ('ORDER BY Add_Date DESC Limit 30');
my $cats = [35,42];
my $cond = GT::SQL::Condition->new( 'CategoryID','IN', $cats); $cond->not; my $cond2 = GT::SQL::Condition->new($cond, 'isValidated','=','Yes'); $sth = $search_db->select ( $cond2 ); my $x = 0; while ($link = $sth->fetchrow_hashref) {
$link->{'detailed_url'} = "$CFG->{build_detail_url}/$link->{'ID'}$CFG->{build_extension}";
Links::init_date();
$link->{Add_Date} = GT::Date::date_transform ($link->{Add_Date}, $CFG->{date_db_format}, $CFG->{date_user_format});
if ($x < 15) {
$output .= Links::SiteHTML::display('linkfront', $link);
}
else {
$output .= Links::SiteHTML::display('linkfront', $link);
}
$x++;
}
return $output;
}
Mar 8, 2004, 9:49 AM
Veteran (1921 posts)
Mar 8, 2004, 9:49 AM
Post #6 of 21
Views: 6097
Sorry for my bad explanation. Try replacing
sth = $search_db->select ($cond2 );
with
$sth = $search_db->select (['Distinct LinkID','Links.*'], $cond2 );
Also, if you have a prefix on your tables then it will need to be prefix_Links.* rather than Links.* - replacing prefix with whatever your prefix is.
sth = $search_db->select ($cond2 );
with
$sth = $search_db->select (['Distinct LinkID','Links.*'], $cond2 );
Also, if you have a prefix on your tables then it will need to be prefix_Links.* rather than Links.* - replacing prefix with whatever your prefix is.
Mar 12, 2004, 4:10 PM
User (103 posts)
Mar 12, 2004, 4:10 PM
Post #9 of 21
Views: 5983
Ok, and do you have a trick to limit the number of characters from the <%title%> that will be generated by the global ? I mean I use this global to generate a very simple display using a 'linkfront.html' file that only displays the linked title of the links, but I would like to limit it to lets say 40 characters and add "..." where it is cut...
Should the tag be modified ? If yes how ?
Thanks in advance,
Brakkar
Should the tag be modified ? If yes how ?
Thanks in advance,
Brakkar
Mar 12, 2004, 5:33 PM
User (103 posts)
Mar 12, 2004, 5:33 PM
Post #11 of 21
Views: 6014
Well, I try to add this in another variable, and it says it is unable to compile.
Here is the other variable, with your code inside:
sub {
use GT::Date;
my ($output,$sth,$link);
my $days = shift;
my $limit = shift;
my $date = GT::Date::date_get();
my $newdate = GT::Date::date_sub($date,$days);
my $search_db = $DB->table('Links','CatLinks');
$search_db->select_options ("ORDER BY Hits DESC","LIMIT $limit");
my $cond = GT::SQL::Condition->new( 'Add_Date', '>', $newdate, 'isValidated', '=', 'Yes');
if (length($link->{Title} > 40) {
$link->{Title} = substr($link->{Title}, 0, 40) . "...";
}
$sth = $search_db->select (['Distinct LinkID','Links.*'], $cond );
while ($link = $sth->fetchrow_hashref) {
$link->{'detailed_url'} = "$CFG->{build_detail_url}/$link->{'ID'}$CFG->{build_extension}";
$output .= Links::SiteHTML::display ('poplinkfront', $link);
}
return $output;
}
Do you know why it doesn't work ?
Thanks in advance,
Brakkar
Here is the other variable, with your code inside:
Quote:
sub {
use GT::Date;
my ($output,$sth,$link);
my $days = shift;
my $limit = shift;
my $date = GT::Date::date_get();
my $newdate = GT::Date::date_sub($date,$days);
my $search_db = $DB->table('Links','CatLinks');
$search_db->select_options ("ORDER BY Hits DESC","LIMIT $limit");
my $cond = GT::SQL::Condition->new( 'Add_Date', '>', $newdate, 'isValidated', '=', 'Yes');
if (length($link->{Title} > 40) {
$link->{Title} = substr($link->{Title}, 0, 40) . "...";
}
$sth = $search_db->select (['Distinct LinkID','Links.*'], $cond );
while ($link = $sth->fetchrow_hashref) {
$link->{'detailed_url'} = "$CFG->{build_detail_url}/$link->{'ID'}$CFG->{build_extension}";
$output .= Links::SiteHTML::display ('poplinkfront', $link);
}
return $output;
}
Do you know why it doesn't work ?
Thanks in advance,
Brakkar
Mar 12, 2004, 5:57 PM
Enthusiast (854 posts)
Mar 12, 2004, 5:57 PM
Post #12 of 21
Views: 5990
It needs to go after:
but before:
Philip
------------------
Limecat is not pleased.
Code:
while ($link = $sth->fetchrow_hashref) {Code:
$output .= Links::SiteHTML::display ('poplinkfront', $link);Philip
------------------
Limecat is not pleased.
Last edited by:
fuzzy logic: Mar 12, 2004, 5:59 PM
Mar 12, 2004, 6:07 PM
User (103 posts)
Mar 12, 2004, 6:07 PM
Post #14 of 21
Views: 5999
Hmmm, I tried:
sub {
use GT::Date;
my ($output,$sth,$link);
my $days = shift;
my $limit = shift;
my $date = GT::Date::date_get();
my $newdate = GT::Date::date_sub($date,$days);
my $search_db = $DB->table('Links','CatLinks');
$search_db->select_options ("ORDER BY Hits DESC","LIMIT $limit");
my $cond = GT::SQL::Condition->new( 'Add_Date', '>', $newdate, 'isValidated', '=', 'Yes');
$sth = $search_db->select (['Distinct LinkID','Links.*'], $cond );
while ($link = $sth->fetchrow_hashref) {
if (length($link->{Title} > 40) {
$link->{Title} = substr($link->{Title}, 0, 40) . "...";
}
$output .= Links::SiteHTML::display ('poplinkfront', $link);
}
return $output;
}
But it still can't compile...
Cordially,
Brakkar
sub {
use GT::Date;
my ($output,$sth,$link);
my $days = shift;
my $limit = shift;
my $date = GT::Date::date_get();
my $newdate = GT::Date::date_sub($date,$days);
my $search_db = $DB->table('Links','CatLinks');
$search_db->select_options ("ORDER BY Hits DESC","LIMIT $limit");
my $cond = GT::SQL::Condition->new( 'Add_Date', '>', $newdate, 'isValidated', '=', 'Yes');
$sth = $search_db->select (['Distinct LinkID','Links.*'], $cond );
while ($link = $sth->fetchrow_hashref) {
if (length($link->{Title} > 40) {
$link->{Title} = substr($link->{Title}, 0, 40) . "...";
}
$output .= Links::SiteHTML::display ('poplinkfront', $link);
}
return $output;
}
But it still can't compile...
Cordially,
Brakkar
Mar 12, 2004, 6:28 PM
Enthusiast (854 posts)
Mar 12, 2004, 6:28 PM
Post #17 of 21
Views: 6002
Unfortunately that's about the extent to which I can help anyone in Links SQL. I'm a long time Links 2.0 user (4+ years), but I've only been running Links SQL for a few weeks now, so I have to say so far I'm not too bright when it comes to all these new features.
Philip
------------------
Limecat is not pleased.
Philip
------------------
Limecat is not pleased.
Mar 13, 2004, 4:47 AM
Veteran (1921 posts)
Mar 13, 2004, 4:47 AM
Post #18 of 21
Views: 5964
Just an extra tip to add onto Fuzzy logic's mod:
if (length($link->{Title}) > 40) {
$link->{Title} = substr($link->{Title}, 0, 40);
$link->{Title} =~ s/\s\S*$//; #This line should stop half a word appearing at the end of the Title
$link->{Title} .= "...";
}
if (length($link->{Title}) > 40) {
$link->{Title} = substr($link->{Title}, 0, 40);
$link->{Title} =~ s/\s\S*$//; #This line should stop half a word appearing at the end of the Title
$link->{Title} .= "...";
}
Mar 15, 2004, 6:40 AM
User (103 posts)
Mar 15, 2004, 6:40 AM
Post #19 of 21
Views: 5972
OK, here is one of the global i'm using:
sub {
# Displays the newest links on the home page.
my ($output,$sth,$link);
my $search_db = $DB->table('Links','CatLinks');
$search_db->select_options ('ORDER BY Add_Date DESC Limit 7');
my $cats = [5,14,17,12,11,33,35,34,8];
my $cond = GT::SQL::Condition->new( 'CategoryID','IN', $cats); my $cond2 = GT::SQL::Condition->new($cond, 'isValidated','=','Yes'); $sth = $search_db->select (['Distinct LinkID','Links.*'], $cond2 ); my $x = 0; while ($link = $sth->fetchrow_hashref) {
$link->{'detailed_url'} = "$CFG->{build_detail_url}/$link->{'ID'}$CFG->{build_extension}";
Links::init_date();
$link->{Add_Date} = GT::Date::date_transform ($link->{Add_Date}, $CFG->{date_db_format}, $CFG->{date_user_format});
if ($x < 3) {
$output .= Links::SiteHTML::display('link2', $link);
}
else {
$output .= Links::SiteHTML::display('poplinkfront2', $link);
}
$x++;
}
return $output;
}
For some reason, when I add the <%if isNew%> tag on my link2.html and poplinkfront2.html templates, ALL the links produced by this global will be flagged as NEW even if they are not. My new link cut off is 2 days, and even a link 1 year old displayed by this global will be considered new.
Does anyone know why ?
Thanks in advance,
Brakkar
sub {
# Displays the newest links on the home page.
my ($output,$sth,$link);
my $search_db = $DB->table('Links','CatLinks');
$search_db->select_options ('ORDER BY Add_Date DESC Limit 7');
my $cats = [5,14,17,12,11,33,35,34,8];
my $cond = GT::SQL::Condition->new( 'CategoryID','IN', $cats); my $cond2 = GT::SQL::Condition->new($cond, 'isValidated','=','Yes'); $sth = $search_db->select (['Distinct LinkID','Links.*'], $cond2 ); my $x = 0; while ($link = $sth->fetchrow_hashref) {
$link->{'detailed_url'} = "$CFG->{build_detail_url}/$link->{'ID'}$CFG->{build_extension}";
Links::init_date();
$link->{Add_Date} = GT::Date::date_transform ($link->{Add_Date}, $CFG->{date_db_format}, $CFG->{date_user_format});
if ($x < 3) {
$output .= Links::SiteHTML::display('link2', $link);
}
else {
$output .= Links::SiteHTML::display('poplinkfront2', $link);
}
$x++;
}
return $output;
}
For some reason, when I add the <%if isNew%> tag on my link2.html and poplinkfront2.html templates, ALL the links produced by this global will be flagged as NEW even if they are not. My new link cut off is 2 days, and even a link 1 year old displayed by this global will be considered new.
Does anyone know why ?
Thanks in advance,
Brakkar