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

meta keywords and description in detail.html

Quote Reply
meta keywords and description in detail.html
Hi Andy,
just to be sure, that I'm doing nothing stupid.
Can you have a look at my attempt to get meta data in detail.html?

Code:
<title><%site_title%> | Download - <%Title%></title>
<meta name="description" content="<%Plugins::ULTRAGlobals::Trim_Field(0,100,$Description)%>" />
<meta name="keywords" content="<%meta_keywords%>" />
the description is called from your ultra globals

the keywords are called with this global

Code:
sub {
my $tags = GT::Template->tags;
my @words = split(/\s+/,$tags->{Title});
my @links;

foreach (@words){
s/^\s*//sg;
s/[\.,]$//sg;
next if length($_)<4;
push(@links,qq|$_|);
}

return join(", ",@links);

}

What do you think?

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] meta keywords and description in detail.html In reply to
Hi,

All looks fine to me - does it not work?

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] meta keywords and description in detail.html In reply to
Hi Andy,
it works fine, but I don't know if I need the @links part in the meta_keywords global.
Cause there are no links only keywords!?!

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] meta keywords and description in detail.html In reply to
The @links part is just an oversight. If you notice, it also has:

push(@links,qq|$_|);

...as well as returning join(",",@links) ... so don't remove it =)

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] meta keywords and description in detail.html In reply to
Ok, thanks

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] meta keywords and description in detail.html In reply to
Hi Andy,
I have many "some text" in my links descriptions.
Today I saw that google scanned all my descriptions, but only to the first "

Do you have an idea why google has a problem with " and what I can do to solve this...?

Thanks

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] meta keywords and description in detail.html In reply to
Maybe try escaping them - i.e converting to &quot;

..something like:

<%escape_html Description%>

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] meta keywords and description in detail.html In reply to
Andy wrote:
Maybe try escaping them - i.e converting to &quot;

..something like:

<%escape_html Description%>

Cheers

What do you think? Will this code work?
Code:
<meta name="description" content="<%Plugins::ULTRAGlobals::Trim_Field(0,100,$escape_html Description)%>" />

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] meta keywords and description in detail.html In reply to
Nah, before you call that bit - try doing:

<%set Description = escape_html Description%>

...then it should work.

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] meta keywords and description in detail.html In reply to
Andy wrote:
Nah, before you call that bit - try doing:

<%set Description = escape_html Description%>

...then it should work.

Cheers

The problem is, I need escape html only in the header for the meta description tag and not in the whole page.
Where should I add
Code:
<%set Description = escape_html Description%>
exactly?

Thanks

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] meta keywords and description in detail.html In reply to
For valid XHTML, you need it escaped everywhere ;)

Yust add it to the top of category.html:

Code:
<%set Description = escape_html Description%>

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] meta keywords and description in detail.html In reply to
No, you get me wrong.
All my descriptions already have escape html...
I only need it in your Plugin.
<%Plugins::ULTRAGlobals::Trim_Field(0,100,$Description)%>

Is there a way to include escape html in your ultraglobals.pm file?
Code:
sub Trim_Field {

my $start = $_[0] || 0;
my $end = $_[1];
my $string = $_[2];

if (length($string) > $end) {

my $tmp = substr($string, $start, $end) . "...";
return \$tmp;

} else {
return $string;
}

}

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] meta keywords and description in detail.html In reply to
Ah ok, just do this then:

Code:
my $string = GT::CGI::escape_html($_[2]);

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] meta keywords and description in detail.html In reply to
Andy wrote:
Ah ok, just do this then:

Code:
my $string = GT::CGI::escape_html($_[2]);


Cheers

Upps I get the following error
Code:
Unknown method 'escape_html' called at .../admin/Plugins/ULTRAGlobals.pm line 1023.

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] meta keywords and description in detail.html In reply to
Found the error. Should be
Code:
my $string = GT::CGI::html_escape($_[2]);

Matthias
gpaed.de
Quote Reply
Re: [Andy] meta keywords and description in detail.html In reply to
Hi Andy, don't know if it's a problem, but I have line breaks in my meta description?!?
http://www.gpaed.de/Detailed/14350.html
Would it be better to have one line of meta description?

Is there a way to prevent a line break in the global?
Thanks

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] meta keywords and description in detail.html In reply to
Try this:

$string =~ s/\n/ /sig;

..after the :

my $string = ....

...stuff

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] meta keywords and description in detail.html In reply to
Hi Andy, I tried this code, but nothing changes ?
Code:
sub Trim_Field {

my $start = $_[0] || 0;
my $end = $_[1];
my $string = GT::CGI::html_escape($_[2]);
$string =~ s/\n/ /sig;
if (length($string) > $end) {

my $tmp = substr($string, $start, $end) . "...";
return \$tmp;

} else {
return $string;
}

}

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] meta keywords and description in detail.html In reply to
Mm, try:

Code:
sub Trim_Field {

my $start = $_[0] || 0;
my $end = $_[1];
my $val = $_[2];
my $string = GT::CGI::html_escape($val);
$string =~ s/[\n\r]/ /sig;
if (length($string) > $end) {

my $tmp = substr($string, $start, $end) . "...";
return \$tmp;

} else {
return $string;
}

}

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] meta keywords and description in detail.html In reply to
Yes that's better. Now there is one line, but the instead of the line break there are two blank spaces and not one.
have a look at http://www.gpaed.de/Detailed/14350.html
After the points there are two blank spaces...

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] meta keywords and description in detail.html In reply to
After:

Code:
$string =~ s/[\n\r]/ /sig;

Add:

Code:
$string =~ s/\s+/ /sg;

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] meta keywords and description in detail.html In reply to
Great, looks fine now.
Thanks

Matthias
gpaed.de