NAVIGATION
This shows you the differences between two versions of the page.
english:technics:title-and-meta-tags [2011/11/29 15:50] Knut Heermann (flip-flop) |
english:technics:title-and-meta-tags [2018/06/03 18:09] (current) |
||
---|---|---|---|
Line 14: | Line 14: | ||
There are several ways to change the browser title //(browser title)// and the meta-description //(description)//. | There are several ways to change the browser title //(browser title)// and the meta-description //(description)//. | ||
- | Der am häufigsten vorkommende Fall wird die einmalige Vergabe des Browser-Titels in **ADMIN -> Seitenlayout** unter "**Seitentitel**" sein. Im Feld darunter "**Titel hinzufügen**" wird eingestellt was im Browser-Titel wie ausgegeben werden soll. | + | 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. |
- | Die "meta description" werden meistens direkt unter Vorlagen in den **<head>**-Bereich geschrieben. Die hier eingetragenen Informationen erscheinen nun auf jeder Seite. | + | 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. |
{{:deutsch:technik:title_meta_tags_be_vorlage00_1.gif|}} | {{:deutsch:technik:title_meta_tags_be_vorlage00_1.gif|}} | ||
- | **Ausgabe im Browser:** | + | **Output in Browser:** |
<code html> | <code html> | ||
- | <meta name="keywords" content="Schlüsselwörter aus Vorlage in head, Wort01, Wort02" /> | + | <meta name="keywords" content="keywords as entered in template into head, Word01, Word02" /> |
- | <meta name="description" content="Description aus Vorlage in head" /> | + | <meta name="description" content="Description as per template's head field" /> |
</code> | </code> | ||
- | Der **title**-Tag kann hier nicht angegeben werden, siehe folgender Abschnitt. | + | The **title**-Tag cannot be triggered here - see following chapter. |
\\ | \\ | ||
- | ===== Standard nach der Installation: ===== | + | ===== Default after installation: ===== |
- | **Ausgabe im Browser-Title** | + | **Output in Browser Title** |
{{:deutsch:technik:title_meta_tags_be_browser_title01_1.gif|}} | {{:deutsch:technik:title_meta_tags_be_browser_title01_1.gif|}} | ||
- | **mit den Einstellungen in Seitenlayout:** | + | **with the settings in Page Layout:** |
{{:deutsch:technik:title_meta_tags_be_layout01_1.gif|}} | {{:deutsch:technik:title_meta_tags_be_layout01_1.gif|}} | ||
- | **und Vorlage:** | + | **and template:** |
{{:deutsch:technik:title_meta_tags_be_vorlage01_1.gif|}} | {{:deutsch:technik:title_meta_tags_be_vorlage01_1.gif|}} | ||
Line 47: | Line 47: | ||
\\ | \\ | ||
- | ===== Input in category: ===== | + | ===== Entry in the category: ===== |
- | In **ADMIN -> Seitenstruktur -> Kategorie** Haben wir die Möglichkeit in die Felder "**Seitentitel**" und "**Beschreibung der Seitenebene**" Einträge für den Browser-Titel und die "meta descriptions" vorzunehmen. | + | 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". |
- | Diese Einträge haben nur Gültigkeit, wenn die Artikel im Listenmodus arbeiten, also mehr als ein Artikel in der Kategorie vorhanden ist und die "**Anzahl an Top-Artikel**" entsprechend gesetzt ist. | + | * <del>Diese Einträge haben nur Gültigkeit, wenn die Artikel im Listenmodus arbeiten, also mehr als ein Artikel in der Kategorie vorhanden ist und die "**Anzahl an Top-Artikel**" entsprechend gesetzt ist. \\ Diese Einträge würden die bisher vorgegebenen überschreiben, **wenn der User im FE in der Artikelübersicht steht**.</del> \\ r442: These entries are also written into the **<head>** area (e.g. double "meta description", "meta keywords"). |
- | Diese Einträge würden die bisher vorgegebenen überschreiben, **wenn der User im FE in der Artikelübersicht steht**. | + | * Or there are no entries in the template for "description" and/or "keywords". In this case, the entries of the category used. The "title" can be replaced with a [[english/technics/title-and-meta-tags#scriptpage_titledescriptionkeywords_from_category_into_the_head_area|small script]] //(see below)//. |
+ | |||
+ | \\ | ||
{{:deutsch:technik:title_meta_tags_be_seitenstruktur02_1.gif|}} | {{:deutsch:technik:title_meta_tags_be_seitenstruktur02_1.gif|}} | ||
- | **Artikelzentrale:** | + | **Article center:** |
{{:deutsch:technik:title_meta_tags_be_artikelzentrale02_1.gif|}} | {{:deutsch:technik:title_meta_tags_be_artikelzentrale02_1.gif|}} | ||
Line 63: | Line 65: | ||
<note> | <note> | ||
- | **Die meta description aus der Kategorie überschreibt eine vielleicht vorhandene meta description in der Vorlage.** | + | **The meta description in this category may not be overrides an existing meta description in the template.** [[english/technics/title-and-meta-tags#scriptpage_titledescriptionkeywords_from_category_into_the_head_area|See Script]]. |
</note> | </note> | ||
- | **Ergebnis im Browser:** | + | **Result in the browser:** |
{{:deutsch:technik:title_meta_tags_be_browser_title02_1.gif|}} | {{:deutsch:technik:title_meta_tags_be_browser_title02_1.gif|}} | ||
Line 72: | Line 74: | ||
\\ | \\ | ||
- | ===== Input into the article basis information: ===== | + | ===== Entry in the article basis information: ===== |
- | Zu jedem Artikel können gezielte Informationen zum "Browser-Titel", den "meta descriptions" und den den "meta keywords" hinterlegt werden. | + | For each article, targeted information on the "Browser Title", the "meta descriptions" and the "meta keywords" can be stored. |
{{:deutsch:technik:title_meta_tags_be_artikel02_1.gif|}} | {{:deutsch:technik:title_meta_tags_be_artikel02_1.gif|}} | ||
Line 94: | Line 96: | ||
<note> | <note> | ||
- | **Die meta description aus dem Artikel überschreibt nicht eine vielleicht vorhandene meta description in der Vorlage.** | + | **Die meta description aus dem Artikel überschreibt nicht eine vielleicht vorhandene meta description in der Vorlage.** [[english/technics/title-and-meta-tags#scriptdescription_from_article_into_the_head_area|See also the script to do so]]. |
</note> | </note> | ||
Line 178: | Line 180: | ||
\\ | \\ | ||
- | **Datei:** template/inc_script/**frontend_init**/cat_entries_into_head.php | + | **File:** template/inc_script/**frontend_init**/cat_entries_into_head.php |
<code php |h cat_entries_into_head.php |h> | <code php |h cat_entries_into_head.php |h> | ||
Line 214: | Line 216: | ||
if (!empty($content["struct"][$content["cat_id"]]['acat_info'])) { // is there any content in field categorie description | if (!empty($content["struct"][$content["cat_id"]]['acat_info'])) { // is there any content in field categorie description | ||
- | if (stripos($block["htmlhead"], '<meta name="description"')) { // is the meta tag description st in head | + | 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); | preg_match('/\<meta name="description" content=(.+?)\/\>/im', $block["htmlhead"], $match); | ||
Line 258: | Line 260: | ||
- | \\ | + | |
--- //[[flip-flop@myrealbox.com|Knut Heermann (flip-flop)]] 2010/05/04 16:12// | --- //[[flip-flop@myrealbox.com|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: [[http://forum.phpwcms.org/viewtopic.php?p=134407|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 ([[english/technics/system-variables|$aktion[4]]] = 1). \\ | ||
+ | |||
+ | [[english/technics/system-variables|$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> | ||
+ | ---- | ||
\\ | \\ | ||
- | --- //[[flip-flop@myrealbox.com|Knut Heermann (flip-flop)]] 2010/05/04 16:12// | + | **File:** template/inc_script/frontend_render/article_entries_into_head.php |
+ | |||
+ | <code php |h article_entries_into_head.php |h> | ||
+ | <?php | ||
+ | /* | ||
+ | ************************************************************************** | ||
+ | * DESCRIPTION aus Artikel aus dem Feld Beschreibung: uebernehmen in | ||
+ | * den <head> Bereich wenn das Feld "Beschreibung:" nicht leer ist | ||
+ | * Der Vorhandener TAG "description" in <head> wird geloescht | ||
+ | * Das Script arbeitet im Artikel-Detailmodus | ||
+ | * Datei: template/inc_script/frontend_render/article_entries_into_head.php | ||
+ | * | ||
+ | * 25.02.2012 KH: heermann@planmatrix.de | ||
+ | * ************************************************************************/ | ||
+ | |||
+ | // ------------------------------------------------------------------------ | ||
+ | // 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> | ||
+ | |||
+ | \\ | ||
+ | --- //[[flip-flop@myrealbox.com|Knut Heermann (flip-flop)]] 2012/02/25 01:30// | ||
+ | |||
+ |