Hi, since I am putting the most popular links on my home.html inside a table, what's the easiest way to display the long titles if over certain characters with "..." at the end so it fits in the table nicely?
Aug 3, 2004, 1:21 PM
Veteran / Moderator (18441 posts)
Aug 3, 2004, 1:21 PM
Post #2 of 6
Views: 1546
Hi. Something like this should do :)
http://www.gossamer-threads.com/...i?post=122985#122985
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!
http://www.gossamer-threads.com/...i?post=122985#122985
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!
Hi, that's the post to shorten the description, I am looking for rather to shorten the Title link. The global code for top 10 I am using right now is:
sub {
#Top 10 sites by hits.
my ($output,$sth,$link);
my $id = shift;
my $db = $DB->table ('Links');
$db->select_options ('ORDER BY Hits DESC', 'LIMIT 10');
my $sth = $db->select ( { isValidated => 'Yes'} );
while ($link = $sth->fetchrow_hashref) {
$output .= Links::SiteHTML::display ('top_ten', $link);
}
return $output;
}
I know it's the line around $output needs to be updated... can you help me out real quick? Thanks.
sub {
#Top 10 sites by hits.
my ($output,$sth,$link);
my $id = shift;
my $db = $DB->table ('Links');
$db->select_options ('ORDER BY Hits DESC', 'LIMIT 10');
my $sth = $db->select ( { isValidated => 'Yes'} );
while ($link = $sth->fetchrow_hashref) {
$output .= Links::SiteHTML::display ('top_ten', $link);
}
return $output;
}
I know it's the line around $output needs to be updated... can you help me out real quick? Thanks.
Aug 3, 2004, 1:40 PM
Veteran / Moderator (18441 posts)
Aug 3, 2004, 1:40 PM
Post #4 of 6
Views: 1518
Something like this should work;
# Top 10 sites by hits.
my $length = 100;
my ($output,$sth,$link);
my $id = shift;
my $db = $DB->table ('Links');
$db->select_options ('ORDER BY Hits DESC', 'LIMIT 10');
my $sth = $db->select ( { isValidated => 'Yes'} );
while ($link = $sth->fetchrow_hashref) {
$link->{Title} = substr ($link->{Title}, 0, $length);
$link->{Title} =~ s/\s\S+?$//;
$link->{Title} .= " ...";
$output .= Links::SiteHTML::display ('top_ten', $link);
}
return $output;
}
I'm off to bed now :)
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!
Code:
sub { # Top 10 sites by hits.
my $length = 100;
my ($output,$sth,$link);
my $id = shift;
my $db = $DB->table ('Links');
$db->select_options ('ORDER BY Hits DESC', 'LIMIT 10');
my $sth = $db->select ( { isValidated => 'Yes'} );
while ($link = $sth->fetchrow_hashref) {
$link->{Title} = substr ($link->{Title}, 0, $length);
$link->{Title} =~ s/\s\S+?$//;
$link->{Title} .= " ...";
$output .= Links::SiteHTML::display ('top_ten', $link);
}
return $output;
}
I'm off to bed now :)
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!
I added if statement just like the other old post... seems to work now....
sub {
# Top 10 sites by hits.
my ($output,$sth,$link);
my $id = shift;
my $db = $DB->table ('Links');
$db->select_options ('ORDER BY Hits DESC', 'LIMIT 10');
my $sth = $db->select ( { isValidated => 'Yes'} );
while ($link = $sth->fetchrow_hashref) {
if(length $link->{Title}> 26 ){
$link->{Title} = substr ($link->{Title}, 0, 26 );
$link->{Title} =~ s/\s\S+?$//;
$link->{Title} .= " ...";
}
$output .= Links::SiteHTML::display ('top_ten', $link);
}
return $output;
}
sub {
# Top 10 sites by hits.
my ($output,$sth,$link);
my $id = shift;
my $db = $DB->table ('Links');
$db->select_options ('ORDER BY Hits DESC', 'LIMIT 10');
my $sth = $db->select ( { isValidated => 'Yes'} );
while ($link = $sth->fetchrow_hashref) {
if(length $link->{Title}> 26 ){
$link->{Title} = substr ($link->{Title}, 0, 26 );
$link->{Title} =~ s/\s\S+?$//;
$link->{Title} .= " ...";
}
$output .= Links::SiteHTML::display ('top_ten', $link);
}
return $output;
}