Meta Tags on the wrong place?!

Get help with installation and running phpwcms here. Please do not post bug reports or feature requests here.
Post Reply
Morgenstern
Posts: 19
Joined: Mon 10. Oct 2005, 19:30

Meta Tags on the wrong place?!

Post by Morgenstern »

Hi

I've got a Problem concerning Html Validation and the position of the metatags.

The code phpwcms generates ist the following one:

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<!--
     phpwcms | free open source content management system
     created by Oliver Georgi (oliver at phpwcms dot de) and licensed under GNU/GPL.
     phpwcms is copyright 2003-2005 of Oliver Georgi. Extensions are copyright of
     their respective owners. Visit project page http://www.phpwcms.org for details.
//-->
<html>
<head>
<title>Tanelorn - Offizielle Seite | Willkommen bei Tanelorn</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script src="phpwcms_template/inc_js/frontend.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="phpwcms_template/inc_css/frontend.css" />

<meta name="description" content="Heavy Metal, Band, Live, Power Metal, Home">

</head>
Unfortunately, the position of meta name="description" is not html valid. How can I change the position or what am I making wrong?
User avatar
DeXXus
Posts: 2168
Joined: Fri 28. Nov 2003, 06:20
Location: USA - Florida

Post by DeXXus »

It is caused by the "self-closing" XHTML tag for "link" in the "head" section of the HTML document which causes the parser to infer the end of the "head" section and the beginning of the "body" section (where "link" and "meta" are not allowed; hence the reported error):

Code: Select all

<link rel="stylesheet" type="text/css" href="phpwcms_template/inc_css/frontend.css" />
Morgenstern
Posts: 19
Joined: Mon 10. Oct 2005, 19:30

Post by Morgenstern »

Thanx for the info! Do you have an idea how I can pass through this problem?
User avatar
DeXXus
Posts: 2168
Joined: Fri 28. Nov 2003, 06:20
Location: USA - Florida

Post by DeXXus »

Morgenstern wrote:Thanx for the info! Do you have an idea how I can pass through this problem?
I am guessing that you could:

1. Edit the "self-closing" tag for "<link rel=... />" (in your version of phpWCMS) to the HTML 4.01 convention
-OR-
2. Rearrange the coding, to place "<meta name=... >" above the "self-closing" tag.

( #2 would seem the "preferred" way! )
Morgenstern
Posts: 19
Joined: Mon 10. Oct 2005, 19:30

Post by Morgenstern »

Done. Thanx for the hint!
User avatar
DeXXus
Posts: 2168
Joined: Fri 28. Nov 2003, 06:20
Location: USA - Florida

Post by DeXXus »

You're WELCOME! :D
shihkuang
Posts: 2
Joined: Thu 4. Dec 2008, 21:31

Re: Meta Tags on the wrong place?!

Post by shihkuang »

Could you post how you re-arrange your meta data codes?

I couldn't find the correct place to do that.

Thank you

P.S. version: 1.2.6

Anthony
User avatar
flip-flop
Moderator
Posts: 8178
Joined: Sat 21. May 2005, 21:25
Location: HAMM (Germany)
Contact:

Re: Meta Tags on the wrong place?!

Post by flip-flop »

Backend -> Admin -> templates -> "select your template" -> html head: <head>

Knut
>> HowTo | DOCU | FAQ | TEMPLATES/DOCS << ( SITE )
shihkuang
Posts: 2
Joined: Thu 4. Dec 2008, 21:31

Re: Meta Tags on the wrong place?!

Post by shihkuang »

I don't think that will re-arrange the code.

Here are the codes in content.func.inc.php

Code: Select all

// add possible redirection code (article summary) to $block["htmlhead"];
$block["htmlhead"]  = render_PHPcode($block["htmlhead"]);

$block["htmlhead"]  = $content["redirect"]["code"].$block["htmlhead"]."\n"."\n<!-- position A-->\n";
//$block["htmlhead"] .= '<meta name="generator" content="phpwcms v'.$phpwcms['version']."\">\n";
// insert description meta tag if not definied
if(!stristr($block["htmlhead"], '"description"') && $content["struct"][$aktion[0]]["acat_info"]) {
	$block["htmlhead"] .= '<meta name="description" content="';
	$block["htmlhead"] .= html_specialchars($content["struct"][$aktion[0]]["acat_info"])."\">\n";
}
// insert keywords meta tag if not definied
//if(!stristr($block["htmlhead"], '"keywords"') && !empty($content["articles"][$aktion[1]]["article_keyword"])) {
if(!stristr($block["htmlhead"], '"keywords"') && !empty($content['all_keywords'])) {
	$content['all_keywords'] = explode (",", $content['all_keywords']);
	$content['all_keywords'] = array_map('trim', $content['all_keywords']);
	$content['all_keywords'] = array_diff($content['all_keywords'], array(''));
	$content['all_keywords'] = array_unique($content['all_keywords']);
	$block["htmlhead"] .= '<meta name="keywords" content="';
	$block["htmlhead"] .= html_specialchars(implode(', ', $content['all_keywords']))."\">\n";
}
// new $block['custom_htmlhead'] var (array) for usage in own rendering stuff.
// you will be able to use $GLOBALS['block']['custom_htmlhead']['myheadname']
// always check if you want to use same head code only once
if(count($block['custom_htmlhead'])) {
	$block["htmlhead"] .= implode("\n", $block['custom_htmlhead'])."\n";
}
As you can see the custom_htmlhead is after the meta keywords.

However, the result is the meta keyword is displayed after the custom_htmlhead text ( the place you reply above).

I've tried to re-arrange the codes, but it couldn't do anything.

Any idea?

Thank you
Post Reply