This is an old revision of the document!


Tag in site structure

This RT is to show how with can the help of tags in the page structure, the output of the pages can be influenced.

Assumed problem:

In each of the four seasons is a special CSS files are loaded. In addition to the template, depending on the terminated season e.g., another image is being loaded.



Procedure:

In the site structure in the field “category infotext” by “HOME” (ie ID = 0) is entered a tag which controls the behavior of the RT in /frontend_render/ , e.g.

[JAHRESZEITEN] #Tag1, #Tag2, Tag3,.#Tag4,...[/JAHRESZEITEN]

The wrapper [JAHRESZEITEN] separates the tags from the remaining entries in this field.
Not valid tags are simply disabled by using a leading #. (In the above example the tag Tag3 is active).

<note> Attention, with the next update please ensure that the file config/phpwcms/conf.indexpage.inc.php is previously backed up and after the update compared with the new one. (This is the special case HOME)
Incidentally, the file can be edited via FTP to change the tags 8-) :!: </note>

In the RT, the appropriate tags are also entered, such as (in active state so without adding #)

$my_tags = 'fruehling, sommer, herbst, winter';

On these tags registered here the field “category infotext” is examined. The field is investigated for this entered tags. At the first match, this matched tag is used and processed. There is only one valid tag.

CSS:
A new CSS file is loaded, depending on the day. In order not to change the load sequence of the CSS files, a dummy or a fallback CSS file is created in template/inc_css/* and in the correct place in the template involved.

This CSS file is exactly replaced by the RT at this point. The RT is marked with the name of the CSS file to be swapped:

$my_css  = 'master_template.css';

Attention: note Upper/lower case!

The name of the exchanged CSS file is equal to the name of the tag, e.g.

Tag = sommerCSS-Datei = specific/sommer.css (The replacement CSS files are located in the directory template/inc_css/specific/)

The result is visible here:

No active tag:


The tag “Winter” is active:


Meta-text for “description” if “Home” is active (ID=0 alias=index)



rt_tag_in_site_structure V1.0 26.11.09

Docu: –
Forum: http://forum.phpwcms.org/viewtopic.php?p=121111

Autor: K.Heermann (flip-flop) http://planmatrix.de
CMS Version: >= 1.3
Version: V1.0

Tag: –

Filename: rt_tag_in_site_structure.php

Folder: template/inc_script/frontend_render/

Condition:/config/phpwcms/conf.inc.php

  • $phpwcms['allow_ext_render'] = 1;



Code

rt_tag_in_site_structure

<?php
/**
 * 26.11.09 KH (flip-flop) tags in site structure "category infotext"
 * This RT is to show how with can the help of tags in the page structure, the output of the pages can be influenced.
 *
 * Usage: sample Replacement Tag
 *
 * in the field "category infotext" in site structure (in this example we uses
 * the category HOME)
 *
 * Tag:
 * -> [JAHRESZEITEN]#Fruehling, #Sommer, #Herbst, Winter[/JAHRESZEITEN]
 *    (We trigger on "Winter", there is no # in front)
 *
 * Meta descrition if you want:
 * -> My descrition text for home
 *
 * Corresponding tags/entries in this rt:
 * -> $my_tags = 'FRUEHLING, SOMMER, HERBST, WINTER';
 *
 * encloser:
 * -> $enclose = 'JAHRESZEITEN';
 *
 * dummy/fallback css filename:
 * -> $my_css  = 'master_template.css';
 *
 **/
 
// ----------------------------------------------------------------
// OBLIGATE CHECK FOR PHPWCMS CONSTANTS
if (!defined('PHPWCMS_ROOT')) {die("You Cannot Access This Script Directly, Have a Nice Day.");}
// ----------------------------------------------------------------
 
 
// ist im Feld Beschreibung der Seitenebene" etwas vorhanden?
if (!empty($content["struct"][0]['acat_info']))
{
    // ===== Usereingabe =====================================
        // Vorgabe: Tags eintragen, wie im Infofeld
 
        $enclose = 'JAHRESZEITEN';                        // Umschlieszer
        $my_tags = 'fruehling, sommer, herbst, winter';    // Die Tags
        $my_css  = 'master_template.css';                 // Name der Dummy-CSS Datei bzw.
                                                        // Fallback Datei die ersetzt wird
    // ===== ENDE Usereingabe ================================
 
 
    // Tags abholen aus "HOME" ID=0
    $info = returntagcontent($content["struct"][0]['acat_info'], $enclose);
 
    // irgendeine Tagansammlung vorhanden?
    if ( !empty($info['tag']) )
    {
        $be_tags = explode(',',$info['tag']);    // BE-Tags holen
        $my_tags = strtolower($my_tags);        // normieren
        $tag = '';                                // Hier wird der Tag festgehalten
 
 
        // Vergleich ob ein Tag aus dem BE in der Vorgabe enthalten ist
        foreach ($be_tags as $key => $value)
        {
            $be_tags[$key] = strtolower(trim($value));            // normieren
 
            if (strpos($my_tags, $be_tags[$key]) != false) {     // Tag gefunden
                $tag = $be_tags[$key];
                break;                                            // foreach Abbruch da gefunden
            }
        }
 
 
        // Custom Funktionen, wie CSS austauschen oder Teile im  Template ersetzen
        // =============================================================
        if ( !empty($tag) )
        {
            // wenn Tag vorhanden, dann z.B. Dummy/Fallback-css austauschen
            // die Position in der Reihenfolge der Dateien bleibt eralten
            // -------------------------------------------------------
            $key = array_search($my_css, $block['css']);
            if ($key) $block['css'][$key] = 'specific/'.$tag.'.css';
 
 
            // Ersetzer im Template
            // -------------------------------------------------------
            if ($tag == 'winter') // wenn "winter" dann mache folgendes:
            {
                $content['all'] =
                str_replace('{RANDOM:templates/header-random/normal}',
                            '{RANDOM:templates/free_XL/header-random/weihnachten}',
                            $content['all']);
            }
        }
 
 
        // Das ganze getagge löschen, wenn "Beschreibung der Seitenebene" fuer die description gebraucht
        // ==============================================================================================
        $content["struct"][0]['acat_info'] = replace_cnt_template($content["struct"][0]['acat_info'], $enclose, '');
        $content["struct"][0]['acat_info'] = trim($content["struct"][0]['acat_info']);
 
    }
}
 
?>


english/phpwcms_replacer_rts/frontend_render/tag-site-structure.1259312024.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