Search: Filtering of text

As a result of the content part SEARCH often unwanted text will be shown.

This problem occurs for example in search results from CPs containing images, especially, if they are placed at the very beginning thusly aren't cut off by word count settings of CP search.

Here is an example, how you can filter file names of pictures off the text with a simple trigger.


- All the displayed image file name (xxxxxxx.jpg/gif/png) can be filtered and deleted from the search results.

Docu: –
Forum: Suchergebnisse anpassen

Author: K.Heermann (flip-flop)
CMS Version: >= 1.4x
Version: V1.0 (02.09.2010)


  • $phpwcms['allow_ext_init'] = 1;


File: /template/inc_script/frontend_init/cp_trig_search_filter.php


// -------------------------------------------------------------------------------------------
// obligate check for phpwcms constants
  if (!defined('PHPWCMS_ROOT')) {die("You Cannot Access This Script Directly, Have a Nice Day.");}
// -------------------------------------------------------------------------------------------
 * *****************************************************************************
 * CP search trigger
 * Delete all images xxxx.jpg/gif/png from the search result
 * V1.0  02.09.10 K.Heermann
 * *****************************************************************************
function CP_SEARCH_FILTER($text, & $data) {
    if( $data['acontent_type'] == 13 ) { // content type search = 13
        $search = '/[^\s]+(?=\.(jpg|gif|png))\.\w{3}/i';
//        $search = '/[^\s]+(?=\.(jpg|gif|png))\.(jpg|gif|png)/i';
        $text = preg_replace($search,'', $text);  // Delete image text (xxxx.jpg/gif/png)
    return $text;
} // ---- END function
english/phpwcms_replacer_rts/frontend_init/cp_trigger/cp-search-filter.txt · Last modified: 2018/06/03 18:09 (external edit) 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