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

Help with this Short Description Global?

Quote Reply
Help with this Short Description Global?
I've modified a few globals from the forum to display a short description which can link your rewrite details pages.

The problem is I can't seem to make it return the Title or ($Title) from the global below. Can anyone tell me what's wrong with it? For some reason the code displays $Title as the link ID# on my link.html pages.

Thanks for any help with this!

Code:
sub {
my $id = $_[0];
my $desc = $_[1];
my $chars = $_[2] || '700';
my $build_url = $CFG->{build_root_url};
my $Title = shift;
if (!$desc) { return "No description yet for this site"; }
length $desc < $chars and return $desc;
my $short = substr ($desc, 0, $chars);
$short =~ s/\s\S+?$//;
my $cats = $DB->table('Links')->get_categories($id);
my ($cat_id,$cat_full_name) = each %$cats;
my $cat_url = $DB->table('Category')->as_url($cat_full_name);
$Title =~ y/ \t\r\n?"'#/__/d;
my $detailed_url = "http://www.mysite.com/...itle-$id/$Title.html";
$short .= qq|<b>... <a href="$detailed_url">More</a></b>|;
}
Quote Reply
Re: [Jonze] Help with this Short Description Global? In reply to
Hi Jonze,

It seems that you don't have the return command at the end of the global .Something like below should work

Code:
sub {
my $id = $_[0];
my $desc = $_[1];
my $chars = $_[2] || '700';
my $build_url = $CFG->{build_root_url};
my $Title = shift;
if (!$desc) { return "No description yet for this site"; }
length $desc < $chars and return $desc;
my $short = substr ($desc, 0, $chars);
$short =~ s/\s\S+?$//;
my $cats = $DB->table('Links')->get_categories($id);
my ($cat_id,$cat_full_name) = each %$cats;
my $cat_url = $DB->table('Category')->as_url($cat_full_name);
$Title =~ y/ \t\r\n?"'#/__/d;
my $detailed_url = "http://www.mysite.com/...itle-$id/$Title.html";
$short .= qq|<b>... <a href="$detailed_url">More</a></b>|;
return $Title;
}

Cheers,

Dat

Programming and creating plugins and templates
Blog
Quote Reply
Re: [tandat] Help with this Short Description Global? In reply to
I think you mean't to use this =)


Code:
sub {
my $id = $_[0];
my $desc = $_[1];
my $chars = $_[2] || '700';
my $build_url = $CFG->{build_root_url};
my $Title = shift;

if (!$desc) { return "No description yet for this site"; }
length $desc < $chars and return $desc;
my $short = substr ($desc, 0, $chars);
$short =~ s/\s\S+?$//;
my $cats = $DB->table('Links')->get_categories($id);
my ($cat_id,$cat_full_name) = each %$cats;
my $cat_url = $DB->table('Category')->as_url($cat_full_name);
$Title =~ y/ \t\r\n?"'#/__/d;
my $detailed_url = "http://www.mysite.com/$cat_url/$Title-$id/$Title.html";
$short .= qq|<b>... <a href="$detailed_url">More</a></b>|;
return \$short;
}

Cool

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!