Gossamer Forum
Home : Products : Links 2.0 : Customization :

Snippet of Text - To Full Description?

Quote Reply
Snippet of Text - To Full Description?
I am using templates and have detailed pages on. link.html displays the text for the description field <%Description%> - but is there a way to only show a "snippet" of the description (as it is quite long) for the link so people click through to the FULL description on the detailed page?

The only way I can think of doing this is creating a new field and manually pasting a few lines of text into it - but is there an automatic way?
Quote Reply
Re: [boom] Snippet of Text - To Full Description? In reply to
Not sure if this will work, but you could try editing site_html_templates.pl. Change;

Code:
sub site_html_detailed {
# --------------------------------------------------------
# This routine will build a single page per link. It's only
# really useful if you have a long review for each link --
# or more information then can be displayed in a summary.
#
my %rec = @_;
return &load_template ('detailed.html', {
total => $total,
grand_total => $grand_total,
title_linked => $title_linked,
%rec,
%globals
} );
}

,.... to.....

Code:
sub site_html_detailed {
# --------------------------------------------------------
# This routine will build a single page per link. It's only
# really useful if you have a long review for each link --
# or more information then can be displayed in a summary.
#
my %rec = @_;

my $short_desc = $rec->{Description};

my $char_limit = "20";

my @cut = split(" ",$rec->{short_desc});
$short_desc = "";
foreach (@cut) {
$short_desc .= " " . $_;
if (length($short_desc) >= $char_limit) { $short_desc .= "..."; last; }
}



return &load_template ('detailed.html', {
total => $total,
grand_total => $grand_total,
title_linked => $title_linked,
%rec,
%globals
} );
}

Untested, and my Links 2 is a bit rusty.. so I'mnot sure how its gonna work. You need to call it in detailed.html with <%short_desc%>

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!
Quote Reply
Re: [Andy] Snippet of Text - To Full Description? In reply to
Thank you for the suggestion, but it's coming up with:

Unkown Tag: short_desc

on the LINK.HTML (as that is where I need the short description) - The detailed page should carry the full description.

Do I have to define short_desc elsewhere to make it work?
Quote Reply
Re: [boom] Snippet of Text - To Full Description? In reply to
Sorry,you need to make the changes to site_html_link

Code:
sub site_html_link {
# --------------------------------------------------------
# This routine is used to display what a link should look
# like.

my %rec = @_;

# Set new and pop to either 1 or 0 for templates.
($rec{'isNew'} eq 'Yes') ? ($rec{'isNew'} = 1) : (delete $rec{'isNew'});
($rec{'isPopular'} eq 'Yes') ? ($rec{'isPopular'} = 1) : (delete $rec{'isPopular'});

my $short_desc = $rec{'Description'};
my $char_limit = "20";

my @cut = split(" ",$short_desc);
$short_desc = "";

foreach (@cut) {
$short_desc .= " " . $_;
if (length($short_desc) >= $char_limit) {
$short_desc .= "..."; last;
}


return &load_template ('link.html', {
detailed_url => "$db_detailed_url/$rec{'ID'}$build_extension",
%rec,
%globals
});
}

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!
Quote Reply
Re: [Andy] Snippet of Text - To Full Description? In reply to
Getting this error now:

Error including libraries: Missing right curly or square bracket at /home/blah/public_html/cgi-bin/admin/site_html_templates.pl line 785, at end of line
syntax error at /home/blah/public_html/cgi-bin/admin/site_html_templates.pl line 785, at EOF
Compilation failed in require at nph-build.cgi line 33.

Make sure they exist, permissions are set properly, and paths are set correctly.


This is with the NEW code you pasted above..... Thank you SO much for helping me with this!
Quote Reply
Re: [boom] Snippet of Text - To Full Description? In reply to
At the end of the red code, try adding another }, so it looks like;

}
}

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!
Quote Reply
Re: [Andy] Snippet of Text - To Full Description? In reply to
Still came up with the "uknown tag" error - but fixed it by adding short_desc in the &load_template routine at the bottom....

return &load_template ('link.html', {
detailed_url => "$db_detailed_url/$rec{'ID'}$build_extension",
rate_img => $rate_img,
short_desc => $short_desc,
%rec,
%globals
});

Thanks so much for your help!