Differences

This shows you the differences between two versions of the page.

english:phpwcms_replacer_rts:frontend_render:tag-site-structure [2009/11/27 09:53]
Knut Heermann (flip-flop)
english:phpwcms_replacer_rts:frontend_render:tag-site-structure [2018/06/03 18:09] (current)
Line 13: Line 13:
\\ \\
-**Procedure:** +===== 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. 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.
-<file>[JAHRESZEITEN] #Tag1, #Tag2, Tag3,.#Tag4,...[/JAHRESZEITEN]</file>+<file>[JAHRESZEITEN] #Tag1, #Tag2, Tag3, #Tag4,...[/JAHRESZEITEN]</file>
The wrapper **[JAHRESZEITEN]** separates the tags from the remaining entries in this field. \\ 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). // Not valid tags are simply disabled by using a leading **#**. //(In the above example the tag **Tag3** is active). //
Line 39: Line 40:
-**CSS:** \\+===== Replace css file: ===== 
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. 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.
Line 71: Line 73:
{{:deutsch:ersetzer_rts:frontend_render:be_template03-3_1.gif|}} {{:deutsch:ersetzer_rts:frontend_render:be_template03-3_1.gif|}}
-----+
\\ \\
 +
 +===== Replace content: =====
 +
 +
 +Of course, it is also possible to share certain content.
 +
 +In the lower section of the script **V1.1** are shown some examples //(Custom Functions)//.
 +
 +**Bsp01.:** direct replacement in the template/content //direktes ersetzen im Template/Content//
 +  * The php function ##str_replace('Suchmuster', 'wird ersetzt durch', 'zu durchsuchender Inhalt');## is used. \\ $content['all'] = str_replace('Suchmich Wort',Tolles Wort', $content['all']);
 +
 +\\
 +
 +**Bsp02.:** Replace with wrapper in template/Content
 +
 +In template/content we see e.g.: "Jetzt **[SEASON]**im Jahr ist es farbig**[/SEASON]**."
 +
 +  * With the help of the built-in-funtion ##replace_cnt_template('crawler content', 'TAG', 'is replaced by');## it can quite easily be implemented. \\ $content['all'] = replace_cnt_template($content['all'], SEASON, 'im Winter ist es weiß');
 +
 +
 +
 +\\
 +
 +**Bsp03.:** Replacing with tag **{TAG}** in template/content
 +
 +In template/content we see e.g.: "Jetzt ist der **{SEASON}** da."
 +
 +  *  As noted above, here the php function ##str_replace(...); ## used. \\ $content['all'] = str_replace('{SEASON}', 'Winter', $content['all']);
 +
 +\\
 +
 +The safe side now needs to be examined whether there are wrapped-snippets are present in the content //(This happens for example if no TAG is true )//.
 +
 +In addition we must have a look to the pre-setting //(fallback)// like e.g., **{ERSETZE}**. If no tag from our list matches, a default value must be registered here. \\
 +
 +  * $content['all'] = str_replace('{ERSETZE}', 'default value', $content['all']);  
 +
 +
 +
 +
 +
 +
 +
 +\\
 +
 +
 +
 +===== Code: =====
 +
**rt_tag_in_site_structure** V1.0  26.11.09   **rt_tag_in_site_structure** V1.0  26.11.09  
Line 98: Line 149:
----- 
----- 
\\ \\
-===== Code ===== 
 +----
 +\\
 +
 +**V 1.0:**
<code php |h rt_tag_in_site_structure |h > <code php |h rt_tag_in_site_structure |h >
<?php <?php
Line 205: Line 257:
} }
} }
 +
 +?>
 +</code>
 +
 +\\
 +**V1.1**: Exemplary extended by several Replacer for the content //(See section "Custom Functions")//.
 +
 +<code php |h rt_tag_in_site_structure |h >
 +<?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.
 + * V1.1
 + *
 + * 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/Content ersetzen
 + // ====================================================================
 +
 + // TAG ueberhaupt vorhanden und TAG in unserer Menge enthalten?
 + if ( (!empty($tag)) AND (strpos($my_tags, $tag) != false) )
 + {
 + // 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';
 + // -------------------------------------------------------
 +
 + // -------------------------------------------------------
 + // Bsp01.: direktes ersetzen im Template/Content
 + // -------------------------------------------------------
 + 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']);
 + }
 + // -------------------------------------------------------
 + // Bsp02.: Ersetzen mit Umschlieszer (wrapper) im Template/Content
 + // In der Vorlage/Content z.B.:
 + // "Jetzt [SEASON]im Jahr ist es farbig[/SEASON]."
 + // -------------------------------------------------------
 +
 + switch($tag) {
 +
 + // Verwendet wird die Funktion:
 + // replace_cnt_template($text='', $tag='', $value='');
 +
 + case 'winter':
 + $content['all'] =
 + replace_cnt_template($content['all'], SEASON, 'im Winter ist es weiß');
 + break;
 +
 + case 'fruehling':
 + $content['all'] =
 + replace_cnt_template($content['all'], SEASON, 'im Fr&uuml;hling ist es gr&uuml;n');
 + break;
 +
 + case 'sommer':
 + $content['all'] =
 + replace_cnt_template($content['all'], SEASON, 'im Sommer ist es gelb');
 + break;
 +
 + case 'herbst':
 + $content['all'] =
 + replace_cnt_template($content['all'], SEASON, 'im Herbst ist es braun');
 + break;
 +
 + }
 +
 + // -------------------------------------------------------
 + // Bsp03.: Ersetzen mit Tag {TAG} im Template/Content
 + // In der Vorlage/Content z.B.:
 + // "Jetzt ist der {SEASON} da."
 + // -------------------------------------------------------
 +
 + switch($tag) {
 +
 + case 'winter':
 + $content['all'] = str_replace('{SEASON}', 'Winter', $content['all']);
 +
 + case 'fruehling':
 + $content['all'] = str_replace('{SEASON}', 'Fr&uuml;hling', $content['all']);
 +
 +
 + case 'sommer':
 + $content['all'] = str_replace('{SEASON}', 'Sommer', $content['all']);
 +
 + case 'herbst':
 + $content['all'] = str_replace('{SEASON}', 'Herbst', $content['all']);
 +
 +
 + }
 + // -------------------------------------------------------
 +
 +
 + } // ---ENDE if ( !empty($tag) ) -------------------------
 +
 +
 +
 + // All unsere [wrapper] und {Tags} in der Vorlage/Content loeschen,
 + // wenn noch vorhanden   (wenn kein Tag gesetzt wurde)
 + // und Fallback setzt bei {TAG}
 + // --------------------------------------------------------------------
 + $content['all'] = str_replace('{SEASON}', 'Regen', $content['all']);  // Fallback
 + $content['all'] = preg_replace('/\[SEASON\](.*?)\[\/SEASON\]/is', '$1', $content['all']);
 + // --------------------------------------------------------------------
 +
 +
 + // Loeschen des ganze "Getagges" in der Struktuebene,
 + // wenn "Beschreibung der Seitenebene" fuer die description gebraucht wird
 + // ---------------------------------------------------------------------
 + $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']);
 + // ---------------------------------------------------------------------
 +
 + }  // ---ENDE if ( !empty($info['tag']) ) -------------------------
 +
 +}  // ---ENDE if (!empty($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