This is an old revision of the document!


Title and meta-Tags

FIXME 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.


Default after installation:

Output in Browser Title

with the settings in Page Layout:

and template:


Entry in the category:

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.
    Diese Einträge würden die bisher vorgegebenen überschreiben, wenn der User im FE in der Artikelübersicht steht.

    r442: These entries are also written into the <head> area (e.g. double “meta description”, “meta keywords”).
  • 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 small script (see below).


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:


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.

In ARTIKEL → Artikel bearbeiten → Artikelinformation [EDIT] → Artikel Basisinformation
kann in den Feldern “Seitentitel:” der “Browser-Titel” in “Beschreibung:” die “meta description” und im Feld Schlüsselwört. die “meta keywords” eingetragen werden.

Page title and desciption:

Diese Informationen übersteuern alle anderen Einträge die vorher gemacht wurden, solange der Artikel in der Detailansicht arbeitet.

Der Modus Artikeldetailansicht wird angesprochen wenn,

  1. Nur ein Artikel innerhalb der Kategorie existiert
  2. Im Artikellistenmodus auf “more…” oder “mehr…” geklickt wird.

Sind mehrere Artikel in dieser Kategorie (Listenmodus) vorhanden weiß das System nicht von welchem Artikel die Infos verwendet werden sollen, in diesem Fall greifen die Einträge aus der Kategorie oder wenn nicht vorhanden der Eintrag aus Seitenlayout für den “Browser-Titel”.

<note> Die meta description aus dem Artikel überschreibt nicht eine vielleicht vorhandene meta description in der Vorlage. See also the script to do so. </note>


Keywords:

Die Einträge in Schlüsselwörter haben zwei Funktionen:

  1. Erzeugen des “meta tag keywords”.
  2. Bereitstellen von Suchbegriffen für die interne Suchfunktion.

<note>Zu 1. Die Einträge aus “Schlüsselwörter” werden nur ausgegeben wenn in der Vorlage kein “meta tag keywords” verwendet wird.!!! </note>

Im Artikellistenmodus werden die unterschiedlichen Keywords aller Artikel der Kategorie zusammengefasst.
Bei “more…” oder “mehr…” (Detailansicht) werden die Keywords des angesprochnen Artikels ausgeliefert.


Result in browser:

Im einfachen Artikelmodus:

  <meta name="description" content="meta description aus Artikel" />
  <meta name="keywords" content="Artikel, Cat03, Wort01, Wort02" />


Im Artikellistenmodus:

Mit Keywords aus Artikel Cat03-1: “Artikel, Cat03-1, Wort03, Wort04”

  <meta name="description" content="meta description aus Kategorie" />
  <meta name="keywords" content="Artikel, Cat03, Wort01, Wort02, Cat03-1, Wort03, Wort04" />


Script: page title/description/keywords from category into the <head> area

FIXME 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:

<meta  name= "description"   content=xyz"/>

Richtig:

<meta name="description" content=xyz" />


  • 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 (max. 255 Zeichen ohne CMS-Patch), wenn
    • das Feld “Schlüsselwört.:” nicht leer ist
    • Vorhandener TAG “keywords” in <head> wird überschrieben


File: template/inc_script/frontend_init/cat_entries_into_head.php

cat_entries_into_head.php

<?php
// ----------------------------------------------------------------------------------------------
// obligate check for phpwcms constants
if (!defined('PHPWCMS_ROOT')) {die("You Cannot Access This Script Directly, Have a Nice Day."); }
// ----------------------------------------------------------------------------------------------
 
/*
 *********************************************************************
 * TITLE aus Kategorie aus dem Feld "Seitentitel:" uebernehmen, wenn
 * 1. max. Artikelanz. < 0
 * 2. Feld "Seitentitel:" nicht leer
 *
 * 14.11.2011 KH: heermann@planmatrix.de
 * *******************************************************************/
 
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'];
}
 
 
/*
 *********************************************************************
 * DESCRIPTION aus Kategorie aus dem Feld Beschreibung: uebernehmen,
 * wenn das Feld "Beschreibung der Seitenebene:" nicht leer ist
 * Vorhandener TAG "description" in <head> wird ueberschrieben
 *
 * 16.11.2011 KH: heermann@planmatrix.de
 * *******************************************************************/
 
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']);
}
 
 
/*
 *********************************************************************
 * KEYWORDS aus Kategorie aus dem Feld "Schluesselwoert.:" uebernehmen,
 * wenn das Feld "Schluesselwoert.:" nicht leer ist
 * Vorhandener TAG "keywords" in <head> wird ueberschrieben
 * Max. 255 Zeichen ohne CMS-Patch
 *
 * 16.11.2011 KH: heermann@planmatrix.de
 * *******************************************************************/
 
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']);
}
 
 
// *******************************************************************
 
 
?>

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:

<meta  name= "description"   content=xyz"/>

correct:

<meta name="description" content=xyz" />


File: template/inc_script/frontend_render/article_entries_into_head.php

article_entries_into_head.php

<?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"]
 
}
 
?>


Knut Heermann (flip-flop) 2012/02/25 01:30

english/technics/title-and-meta-tags.1330168274.txt.gz · Last modified: 2018/06/03 18:08 (external edit)
www.planmatrix.de www.chimeric.de Creative Commons License Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0