NAVIGATION
This is an old revision of the document!
translate
: title
: meta description
: meta keywords
Relationships between the various settings in page layout, page structure and article.
There are several ways to change the browser title (browser title) and the meta-description (description).
The most common case will be one-time definition of the title for the browser title bar, this is done in ADMIN → page layout via “page title” . The field “add to title:” below is for adjusting the additional output combinations in the browser title bar.
The “meta description” mostly will be entered directly into the <head>-area under templates. These instructions entered here will produce their output on each page now.
Output in Browser:
<meta name="keywords" content="keywords as entered in template into head, Word01, Word02" /> <meta name="description" content="Description as per template's head field" />
The title-Tag cannot be triggered here - see following chapter.
In ADMIN → site structure → category we can type in entries into the fields “page title:” for the browser title and “category infotext:” for the “meta descriptions”.
Article center:
<note>
The meta description in this category may not be overrides an existing meta description in the template. See Script.
</note>
Result in the browser:
In ARTIKEL → Artikel bearbeiten → Artikelinformation [EDIT] → Artikel Basisinformation
Im einfachen Artikelmodus:
<code html>
<meta name=“description” content=“meta description aus Artikel” />
<meta name=“keywords” content=“Artikel, Cat03, Wort01, Wort02” />
</code>
===== Script: page title/description/keywords from category into the <head> area =====
translate
Problem: In der Vorlage stehen in “title”, “meta description” und “meta keywords” Daten, die für bestimmte Seiten (Kategorien) geändert werden müssten.
Bisher war das lediglich durch eine andere Vorlage/Seitenlayout oder durch Einträge im Artikelkopf möglich oder eben “Artikel im Listenmodus” (siehe oben).
Die Idee bei diesem Script besteht darin, dass die Inhalte von “title”, “meta description” und “meta keywords” einfach aus den vorhandenen Feldern der Kategorie genommen und eingesetzt werden.
Ist ein Kategoriefeld mit Werten gefüllt, werden diese übernommen, wenn nicht, bleiben die Werte aus der Vorlage aktiv. Dieses Script überschreibt also vorhandene Werte die in der Vorlage stehen.
Damit das auch funktioniert müssen die Einträge für description und keywords in der Vorlage sauber aufgebaut sein was die Leerzeichen für die Notation im Bezeichner betrifft.
Falsch:
<code>
<meta name= “description” content=xyz”/>
</code>
Richtig:
<code>
<meta name=“description” content=xyz” />
</code>
* Title aus Kategorie im Feld “Seitentitel:” übernehmen, wenn
* 1. max. Artikelanzahl < 0
* 2. Feld Seitentitel: nicht leer
* DESCRIPTION aus Kategorie aus dem Feld Beschreibung: übernehmen, wenn
* das Feld “Beschreibung der Seitenebene:” nicht leer ist
* Vorhandener TAG “description” in <head> wird überschrieben
* KEYWORDS aus Kategorie aus dem Feld “Schlüsselwört.:” übernehmen
obligate check for phpwcms constants if (!defined('PHPWCMS_ROOT')) {die(“You Cannot Access This Script Directly, Have a Nice Day.”); } ———————————————————————————————-
if ( ($content[“struct”][$content[“cat_id”]]['acat_topcount'] < 0) AND
(!empty($content["struct"][$content["cat_id"]]['acat_pagetitle'])) ) {
$content['pagetitle'] = $content["struct"][$content["cat_id"]]['acat_pagetitle'];
}
if (!empty($content[“struct”][$content[“cat_id”]]['acat_info'])) { is there any content in field categorie description if (stripos($block[“htmlhead”], '<meta name=“description”')!==false ) { is the meta tag description st in head
preg_match('/\<meta name="description" content=(.+?)\/\>/im', $block["htmlhead"], $match);
if ( isset($match['1']) AND !empty($match['1']) ) // if match found, replace
$block["htmlhead"] = str_ireplace('<meta name="description" content='.$match['1'], '<meta name="description" content="'.$content["struct"][$content["cat_id"]]['acat_info'].'" ', $block["htmlhead"]);
} else // is the meta tag description is not set in head, generate a new one
set_meta('description', $content["struct"][$content["cat_id"]]['acat_info']);
}
if ( !empty($content[“struct”][$content[“cat_id”]]['acat_keywords']) ) { is there any content in field categorie keywords if (stripos($block[“htmlhead”], '<meta name=“keywords”')) { is the meta tag keywords set in head
preg_match('/\<meta name="keywords" content=(.+?)\/\>/im', $block["htmlhead"], $match);
if ( isset($match['1']) AND !empty($match['1']) ) // if match found, replace
$block["htmlhead"] = str_ireplace('<meta name="keywords" content='.$match['1'], '<meta name="keywords" content="'.$content["struct"][$content["cat_id"]]['acat_keywords'].'" ', $block["htmlhead"]);
} else // is the meta tag keywords is not set in head, generate a new one
set_meta('keywords', $content["struct"][$content["cat_id"]]['acat_keywords']);
}
*
?>
</code>
— Knut Heermann (flip-flop) 2010/05/04 16:12
===== Script: Description from article into the <head> area =====
Problem:
> In all articles we can create meta descriptions that are also shown wonderful. I would not do this for all articles and deposit, therefore, a default description in the original. Unfortunately, on all sides are double meta-descriptions shown if a description is listed in the article.
Forum: default meta description
Solution:
Description, keywords and title should actually be applied in every category. That was probably the original idea. In this case, these values are overwritten by the entries in the item automatically, if available.
However, almost every user put these values directly into the template and this can not be controlled by the system afterwards.
The script shown above will overwrite the existing entries in <head> with the values of the category.
That does not help when in <head> data are available and the articles there also enters his data.
So a script can be created (in /frontend_render/..) that is similar to the one shown above. (runs much earlier in /frontend:init/..).
In stupid manner in $content['articles'] the DB field of the table article_description phpwcms_article is not carried, so it needs an additional DB access.
The whole thing should work only if the article is presented in detail mode ($aktion[4] = 1).
$aktion[1] beinhaltet die Artikel-ID.
—-
This script will overwrite existing values that are in the template.
For this to work well, the entries for description and keywords in the template to be built cleanly. This applies to the notation of the spaces in the identifier.
Wrong:
<code>
<meta name= “description” content=xyz”/>
</code>
correct:
<code>
<meta name=“description” content=xyz” />
</code>
—-
File: template/inc_script/frontend_render/article_entries_into_head.php
<code php |h article_entries_into_head.php |h>
<?php
————————————————————————
obligate check for phpwcms constants
if (!defined('PHPWCMS_ROOT')) {
die(“You Cannot Access This Script Directly, Have a Nice Day.”); }
————————————————————————
Nur wenn in Artikel-Listenansicht und zu ersetzender String vorhanden
if ($aktion[4] == 1) { Modus article detail (1) sonst article list (0)
if (stripos($block[“htmlhead”], '<meta name=“description”')!==false ) { is the meta tag description in head
Beschreibung (description) in diesem Artikel vorhanden?
$article_sql = “SELECT article_description FROM ”.DB_PREPEND.”phpwcms_article ”;
$article_sql .= “WHERE article_aktiv =1 AND article_id = ”.$aktion[1];
$result = _dbQuery($article_sql);
Artikelbeschreibung in der DB vorhanden?
if (isset($result[0]['article_description']) AND !empty($result[0]['article_description'])) {
Vorhandene description in <head> loeschen
$block[“htmlhead”] = preg_replace('/\<meta name=“description”\s*content=.+?\/\>/im', '',$block[“htmlhead”]);
}
}
Beschreibung aus Artikel wird autom. eingetragen, bzw. steht nicht in $block[“htmlhead”]
}
?>
</code>
— Knut Heermann (flip-flop) 2012/02/25 01:30