Page 1 of 1
Meta Tags on the wrong place?!
Posted: Tue 17. Oct 2006, 21:53
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?
Posted: Wed 18. Oct 2006, 00:51
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" />
Posted: Wed 18. Oct 2006, 09:42
by Morgenstern
Thanx for the info! Do you have an idea how I can pass through this problem?
Posted: Wed 18. Oct 2006, 13:07
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! )
Posted: Thu 19. Oct 2006, 15:52
by Morgenstern
Done. Thanx for the hint!
Posted: Thu 19. Oct 2006, 16:32
by DeXXus
You're WELCOME!

Re: Meta Tags on the wrong place?!
Posted: Wed 10. Dec 2008, 02:36
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
Re: Meta Tags on the wrong place?!
Posted: Wed 10. Dec 2008, 10:14
by flip-flop
Backend -> Admin -> templates -> "select your template" -> html head: <head>
Knut
Re: Meta Tags on the wrong place?!
Posted: Wed 10. Dec 2008, 20:25
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