This is an old revision of the document!


Search: Filtering of text

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

Im Ergebnis des Contentparts SUCHE werden häufig unerwünschte Textteile dargestellt. 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.

Description:

- 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) http://planmatrix.de
CMS Version: >= 1.4x
Version: V1.0 (02.09.2010)

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

  • $phpwcms['allow_ext_init'] = 1;



PHP:

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

cp_trig_search_filter.php

<?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  http://planmatrix.de
 *
 * *****************************************************************************
*/
 
 
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
 
register_cp_trigger('CP_SEARCH_FILTER');
 
?>
english/phpwcms_replacer_rts/frontend_init/cp_trigger/cp-search-filter.1283453534.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