NAVIGATION
This shows you the differences between two versions of the page.
|
deutsch:ersetzer_rts:frontend_init:cp_trigger [2009/05/18 16:49] Knut Heermann (flip-flop) |
deutsch:ersetzer_rts:frontend_init:cp_trigger [2018/06/03 18:09] (current) |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| {{indexmenu_n>10}} | {{indexmenu_n>10}} | ||
| - | ====== cp_trigger ====== | + | ====== CP-trigger ====== |
| Forum: [[http://forum.phpwcms.org/viewtopic.php?p=107107#p107107]] - Autor: OG | Forum: [[http://forum.phpwcms.org/viewtopic.php?p=107107#p107107]] - Autor: OG | ||
| Line 105: | Line 105: | ||
| Forum: [[http://forum.phpwcms.org/viewtopic.php?p=107107#p107107]] | Forum: [[http://forum.phpwcms.org/viewtopic.php?p=107107#p107107]] | ||
| - | Eine Klasse zu einem Bild hinzuzufügen, das aus dem CP Bilder <div> generiert wird. Gegeben ist diese Ausgabe: | + | Eine Klasse zu einem Bild hinzufügen, das aus dem CP Bilder <div> generiert wird. Gegeben ist diese Ausgabe: |
| - | <code html><img src="content/images/xyz.jpg" alt="Alt-Text" title="Titel-Text" **border="0"** width="120" height="90"></code> | + | <code html><img src="content/images/xyz.jpg" alt="Alt-Text" title="Titel-Text" border="0" width="120" height="90"></code> |
| Die Konstruktion soll strukturell etwa so aussehen: | Die Konstruktion soll strukturell etwa so aussehen: | ||
| Line 114: | Line 114: | ||
| ==== Lösungsmethode: ==== | ==== Lösungsmethode: ==== | ||
| - mit einem Trigger auf **border="0"** und Ersetzung nach **class="MY_CUSTOM_CLASS" border="0"** ergibt: \\ | - mit einem Trigger auf **border="0"** und Ersetzung nach **class="MY_CUSTOM_CLASS" border="0"** ergibt: \\ | ||
| - | <code html><img src="content/images/xyz.jpg" alt="Alt-Text" title="Titel-Text" **class="MY_CUSTOM_CLASS" border="0"** width="120" height="90"></code> | + | <code html><img src="content/images/xyz.jpg" alt="Alt-Text" title="Titel-Text" class="MY_CUSTOM_CLASS" border="0" width="120" height="90"></code> |
| \\ | \\ | ||
| Line 210: | Line 210: | ||
| \\ | \\ | ||
| + | ===== 4. Beispiel: CP_SEARCH_NO_SUMMARY ===== | ||
| + | Der Contentpart //Suche/search// soll im Suchergebnis nur den Artikeltitel ausgeben ohne den Schlagtext (summary). Im Augenblick //(Sept. 2009)// ist es nicht möglich im Feld [max. Anzahl Worte (Summary)] den Wert Null zu führen, da dies als "Alles ausgeben" gewertet wird. | ||
| - | ===== 4. Beispiel: Kürzen des CAPTION-Textes ===== | + | Die Standardausgabe umschließt den gefundenen Schlagtext jeweils mit **<p>... Summary ...</p>**. Also ist es möglich hiernach zu suchen und den gesamten Inhalt von **<p>...</p>** durch eine leere Menge zu ersetzen. |
| - | Bei der Verwendung der CPs //Bilder <div>// und //Bilder Spezial// soll der Captiontext //(Bildunterzeile)// in der einfachen FE-Ausgabe gekürzt werden. In der LightBox bleibt der Text vorhanden. | ||
| - | Angenommener Templateeintrag: | + | Forum: [[http://forum.phpwcms.org/viewtopic.php?p=120031#p120031]] |
| - | <file> | + | |
| - | [CAPTION]<p style="margin:3px 0 0 0; width:200px; height:15px;"><span class="cut_caption">{CAPTION}</span></p>[/CAPTION] | + | |
| - | [CAPTION_ELSE]<p>{IMGNAME}</p>[/CAPTION_ELSE] | + | |
| - | </file> | + | |
| - | Es wird auf die Zeichenfolge ##<span class="cut_caption">## //Caption-Text// ##</span>## getriggert. \\ | + | <code php|h cp_search_no_sum.php |h> |
| - | //Caption-Text// wird somit separiert, ausgelesen und verarbeitet. \\ | + | |
| - | Die Stelle <span ...> .... </span> wird mit dem Ergebnis überschrieben. | + | |
| - | + | ||
| - | In diesem Beispiel werden die Zeichen //substr('$1', **0**, **8**)// von Position 0 bis 8 ausgeschnitten und zurückgegeben. | + | |
| - | + | ||
| - | Ergebnis: Yes We Can //do many things with this cms// -> **Yes We C** | + | |
| - | + | ||
| - | \\ | + | |
| - | + | ||
| - | + | ||
| - | <code php|h cp_trig_cut_caption_text.php |h> | + | |
| <?php | <?php | ||
| // ------------------------------------------------------------------------------------------- | // ------------------------------------------------------------------------------------------- | ||
| Line 239: | Line 225: | ||
| if (!defined('PHPWCMS_ROOT')) { | if (!defined('PHPWCMS_ROOT')) { | ||
| die("You Cannot Access This Script Directly, Have a Nice Day."); } | die("You Cannot Access This Script Directly, Have a Nice Day."); } | ||
| + | // ------------------------------------------------------------------------------------------- | ||
| + | // 01.10.09 KH (flip-flop) Kill all summary entries between <p> and </p> in search result | ||
| // ------------------------------------------------------------------------------------------- | // ------------------------------------------------------------------------------------------- | ||
| - | // Cutting the caption text in FE output (substr('$1', 0, 8) = cutting out charakter 0 to 8) | + | function CP_SEARCH_NO_SUMMARY($text, & $data) { |
| - | // K.Heermann (flip-flop) 17.05.09 | + | |
| - | /* | + | if( $data['acontent_type'] == 13 ) // CP: 13 => search |
| - | * cp_trigger_function_name - the unique function name | + | { |
| - | * $text - holds the content part html source on which you can parse or do custom processing | + | $text = preg_replace("/\<p\>(.*?)\<\/p\>/si", '', $text); // kill all <p> ....</p> |
| - | * $data - is a reference to an array which holds content part values like ID, dates and other values - see db table phpwcms_articlecontent | + | |
| - | + | ||
| - | Always return $text; | + | |
| - | */ | + | |
| - | + | ||
| - | + | ||
| - | /* e.g. Template ------------------------------------------------------------- | + | |
| - | [CAPTION]<p style="margin:3px 0 0 0; width:200px; height:15px;"><span class="cut_caption">{CAPTION}</span></p>[/CAPTION] | + | |
| - | [CAPTION_ELSE]<p>{IMGNAME}</p>[/CAPTION_ELSE] | + | |
| - | ----------------------------------------------------------------------------- */ | + | |
| - | + | ||
| - | function CP_CUT_CAPTION_TEXT($text, & $data) { | + | |
| - | + | ||
| - | + | ||
| - | // CPs: 29 => image <div>, 31 => image special | + | |
| - | if ( $data['acontent_type'] == 29 OR $data['acontent_type'] == 31 ) | + | |
| - | { | + | |
| - | $text = preg_replace("/<span class=\"cut_caption\">(.*?)<\/span>/e","substr('$1', 0, 8).' ...'" , $text); | + | |
| - | + | ||
| - | // First word in string | + | |
| - | // $text = preg_replace("/<span class=\"cut_caption\">(.*?)<\/span>/e","substr('$1', 0, strpos('$1', ' ')).' ...'" , $text); | + | |
| } | } | ||
| - | |||
| return $text; | return $text; | ||
| } | } | ||
| - | + | ||
| - | register_cp_trigger('CP_CUT_CAPTION_TEXT'); | + | register_cp_trigger('CP_SEARCH_NO_SUMMARY'); |
| - | + | ||
| ?> | ?> | ||
| </code> | </code> | ||
| \\ | \\ | ||
| - | |||
| - | ===== 5. Beispiel: Kürzen des CAPTION-Textes V1.1 ===== | ||
| - | |||
| - | Bei der Verwendung der CPs //Bilder <div>// und //Bilder Spezial// soll der Captiontext //(Bildunterzeile)// in der einfachen FE-Ausgabe gekürzt werden. In der LightBox bleibt der Text vorhanden. | ||
| - | |||
| - | Angenommener Templateeintrag: | ||
| - | <file> | ||
| - | [CAPTION]<p style="margin:3px 0 0 0; width:200px; height:15px;"><span class="cut_caption-c20-w3-pword">{CAPTION}</span></p>[/CAPTION] | ||
| - | [CAPTION_ELSE]<p>{IMGNAME}</p>[/CAPTION_ELSE] | ||
| - | </file> | ||
| - | |||
| - | Es wird auf die Zeichenfolge ##<span class="cut_caption####-c20####-w3####-pword####">## //Caption-Text// ##</span>## getriggert. \\ | ||
| - | //Caption-Text// wird somit separiert, ausgelesen und verarbeitet. \\ | ||
| - | V1.1: Zusätlich werden die Parameter in **cut_caption**##-c20####-w3####-pword## getriggert und verarbeitet. | ||
| - | * ##-cXX## -> Ausgabe von max. XX Zeichen | ||
| - | * ##-wXX## -> Ausgabe von max. XX Wörtern | ||
| - | * ##-pXX## -> Modusschalter Zeichen oder Wörter - mit XX =char oder XX=word | ||
| - | Ist der String im Modus [word] länger als max. Zeichen in -cXX angegeben, wird autom. auf den Modus [char] umgeschaltet. | ||
| - | |||
| - | |||
| - | Die Stelle //<span ...> .... </span>// wird mit dem Ergebnis überschrieben. | ||
| - | |||
| - | In diesem Beispiel werden die Zeichen //substr('$1', **0**, **8**)// von Position 0 bis 8 ausgeschnitten und zurückgegeben. | ||
| - | |||
| - | Ergebnis: Yes We Can //do many things with this cms// -> **Yes We C** | ||
| - | |||
| - | \\ | ||
| - | |||
| - | |||
| - | <code php|h cp_trig_cut_caption_text.php |h> | ||
| - | <?php | ||
| - | // ------------------------------------------------------------------------------------------- | ||
| - | // obligate check for phpwcms constants | ||
| - | if (!defined('PHPWCMS_ROOT')) { | ||
| - | die("You Cannot Access This Script Directly, Have a Nice Day."); } | ||
| - | // ------------------------------------------------------------------------------------------- | ||
| - | |||
| - | // Cutting the caption text in FE output (substr('$1', 0, 8) = cutting out charakter 0 to 8) | ||
| - | // K.Heermann (flip-flop) 17.05.09 | ||
| - | |||
| - | /* | ||
| - | * cp_trigger_function_name - the unique function name | ||
| - | * $text - holds the content part html source on which you can parse or do custom processing | ||
| - | * $data - is a reference to an array which holds content part values like ID, dates and other values - see db table phpwcms_articlecontent | ||
| - | |||
| - | Always return $text; | ||
| - | */ | ||
| - | |||
| - | |||
| - | /* e.g. Template ------------------------------------------------------------- | ||
| - | [CAPTION]<p style="margin:3px 0 0 0; width:200px; height:15px;"><span class="cut_caption">{CAPTION}</span></p>[/CAPTION] | ||
| - | [CAPTION_ELSE]<p>{IMGNAME}</p>[/CAPTION_ELSE] | ||
| - | ----------------------------------------------------------------------------- */ | ||
| - | |||
| - | function CP_CUT_CAPTION_TEXT($text, & $data) { | ||
| - | |||
| - | |||
| - | // CPs: 29 => image <div>, 31 => image special | ||
| - | if ( $data['acontent_type'] == 29 OR $data['acontent_type'] == 31 ) | ||
| - | { | ||
| - | $text = preg_replace("/<span class=\"cut_caption\">(.*?)<\/span>/e","substr('$1', 0, 8).' ...'" , $text); | ||
| - | |||
| - | // First word in string | ||
| - | // $text = preg_replace("/<span class=\"cut_caption\">(.*?)<\/span>/e","substr('$1', 0, strpos('$1', ' ')).' ...'" , $text); | ||
| - | } | ||
| - | |||
| - | return $text; | ||
| - | } | ||
| - | |||
| - | register_cp_trigger('CP_CUT_CAPTION_TEXT'); | ||
| - | |||
| - | ?> | ||
| - | </code> | ||