Gossamer Forum
Home : Products : Links 2.0 : Discussions :

How to shorten meta description in detailed pages

Quote Reply
How to shorten meta description in detailed pages
I normally use the description field also as "meta description" in the headers of detailed pages.

Anyone knows how could I cut the description field after the first 130 chars when building the detailed page?
Walter Aresca
http://www.gratis.it
Quote Reply
Re: [musictus] How to shorten meta description in detailed pages In reply to
Been a while since I've played with Links 2, but I think it could be done with something like:


in site_html_templates.pl, find:


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
} );
}

..and add:


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,
trimmed_desc => substr(0,130,$rec{'Meta_Description'})
} );
}

..then, in detailed.html - try using <%trimmed_desc%> where you want the shorter meta-description to show :)

Hope that helps (its not tested =))

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] How to shorten meta description in detailed pages In reply to
Thanks for the hint, but I get "unknown tag". Where must I define this tag?
Walter Aresca
http://www.gratis.it
Quote Reply
Re: [musictus] How to shorten meta description in detailed pages In reply to
Hi,

What tag are you currently using? (where it shows the "full" value of the field)

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] How to shorten meta description in detailed pages In reply to
I added to site_html_templates.pl

trimmed_desc => substr(0,10,$rec{'Description'})

to the template

<meta name="description" content="<%trimmed_desc%>">

and the error I get after building is

Unkown Tag: trimmed_desc

Thanks for your help!
Walter Aresca
http://www.gratis.it
Quote Reply
Re: [musictus] How to shorten meta description in detailed pages In reply to
Mmm.. not sure. As I said, been a while since I played with Links 2 =)

Will have a look tomorrow for you.

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] How to shorten meta description in detailed pages In reply to
suggest...

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 = @_;
$trimmed_desc = substr(0,130,$rec{'Meta_Description'});
return &load_template ('detailed.html', {
total => $total,
grand_total => $grand_total,
title_linked => $title_linked,
trimmed_desc => $trimmed_desc,
%rec,
%globals
} );
}

If that doesn't work, may need to alter routine in nph-build.cgi.


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] How to shorten meta description in detailed pages In reply to
To keep your description from being chopped off after a certain number of characters, you could use this mod, which chops at white space...

http://www.gossamer-threads.com/...?post=288557#p288557

It is based on code from Andy...

http://www.gossamer-threads.com/...?post=285117#p285117


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] How to shorten meta description in detailed pages In reply to
BTW, I think the code I gave should work, but I put the substr() bit wrong =)

trimmed_desc => substr(0,130,$rec{'Meta_Description'})

...should be:

trimmed_desc => substr($rec{'Meta_Description'},0,130)

Whistle

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!