NAVIGATION
This shows you the differences between two versions of the page.
|
english:phpwcms_replacer_rts:frontend_init:cp_trigger [2009/05/17 21:07] Knut Heermann (flip-flop) |
english:phpwcms_replacer_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]] \\ | Forum: [[http://forum.phpwcms.org/viewtopic.php?p=107107#p107107]] \\ | ||
| Line 37: | Line 37: | ||
| </code> | </code> | ||
| - | You can also limit your function to work for special [[:english:phpwcms-system:article:contentparts|content parts]] (especially [[:english:technics:internally-function-call:content-part-types|content part types]]): | + | You can also limit your function to work for special [[:english:phpwcms-system:article:contentparts|content parts]] (especially [[:english:technics:internal-function-call:content-part-types|content part types]]): |
| <code php> | <code php> | ||
| function cp_trigger_function_name($param1, & $param2) { | function cp_trigger_function_name($param1, & $param2) { | ||
| Line 98: | Line 98: | ||
| === Content Part Types === | === Content Part Types === | ||
| - | Please have a look into: [[:deutsch:technik:aufruf-interner-funktionen:content_part_typen|Content Part Types]] | + | Please have a look into: [[:/english/technics/internal-function-call/content-part-types|Content Part Types]] |
| - | ===== Example one: CP_IMGDIV_img_class ===== | + | ===== 1. example: CP_IMGDIV_img_class ===== |
| Forum: [[http://forum.phpwcms.org/viewtopic.php?p=107107#p107107]] | Forum: [[http://forum.phpwcms.org/viewtopic.php?p=107107#p107107]] | ||
| Line 107: | Line 107: | ||
| Add a class to an image, based on the cp image <div>. The given output: | Add a class to an image, based on the cp image <div>. The given output: | ||
| - | <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> |
| The construction structurally is look like: | The construction structurally is look like: | ||
| Line 114: | Line 114: | ||
| ==== Method of resolution: ==== | ==== Method of resolution: ==== | ||
| - using a trigger to **border="0"** and replace to **class="MY_CUSTOM_CLASS" border="0"** ends in this result: \\ | - using a trigger to **border="0"** and replace to **class="MY_CUSTOM_CLASS" border="0"** ends in this result: \\ | ||
| - | <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 211: | Line 211: | ||
| \\ | \\ | ||
| - | ===== 4. example: Shorten the CAPTION text ===== | + | ===== 4. example: CP_SEARCH_NO_SUMMARY ===== |
| - | When using the CPs //image <div>// and //image special//, the caption text is to be shortened for the the simple FE output. In LightBox the whole caption text is available. | ||
| - | Assumed template entry: | + | Using the content part //search// in search result we need only the article title without the summary. |
| - | <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. \\ | + | At this moment (2009/09) a non summary output is not possible. If we insert the value zero into [results per page (summary)] it is the same as an "empty" input. -> (If empty, show all). |
| - | //Caption-Text// wird somit separiert, ausgelesen und verarbeitet. \\ | + | |
| - | Die Stelle <span ...> .... </span> wird mit dem Ergebnis überschrieben. | + | |
| - | It is triggered to the character sequence ##<span class="cut_caption">## //cption-text// ##</span>##. \\ | ||
| - | //caption-Text// is thus separated, selected and processed. \\ | ||
| - | The place <span ...> .... </span> is signed over with the result. | ||
| + | The standard output encloses the found summary in each case with **<p>... Summary ...</p>**. Thus it is possible to search for **<p>...</p>** and replace all **<p>...</p>** by an empty quantity. | ||
| - | \\ | ||
| + | Forum: [[http://forum.phpwcms.org/viewtopic.php?p=120031#p120031]][DE] | ||
| - | <code php|h cp_trig_cut_caption_text.php |h> | + | <code php|h cp_search_no_sum.php |h> |
| <?php | <?php | ||
| // ------------------------------------------------------------------------------------------- | // ------------------------------------------------------------------------------------------- | ||
| Line 239: | Line 230: | ||
| 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 | + | 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, 7).' ...'" , $text); | + | |
| } | } | ||
| - | |||
| return $text; | return $text; | ||
| } | } | ||
| - | + | ||
| - | register_cp_trigger('CP_CUT_CAPTION_TEXT'); | + | register_cp_trigger('CP_SEARCH_NO_SUMMARY'); |
| - | + | ||
| ?> | ?> | ||
| </code> | </code> | ||
| + | |||
| + | \\ | ||
| + | |||