Kann man denn den neuaufbau der suche um zwei neue felder ergänzen? Ich habe beispielsweise den "Neues Feld im Postingbereich" MOD von Acid eingebaut, dadurch gibt es nicht nur den Titel und den Nachrichtentext beim topic erstellen sondern auch noch sozusagen "Titel2". Wenn die searchtabelle vor dem rebuild geleert wird, fehlen mir nach dem rebuild alle einträge zu "Titel2" da diese beim rebuild nicht berücksichtigt werden - is ja auch klar. Erst wenn ich jetzt in jedes Topic gehe und "Titel2" neu poste wirds wieder in die Searchtabelle aufgenommen. Das macht natürlich ein wenig arbeit bei rund 2000 Topics
Deshalb meine frage ob man das nachträglich relativ leicht mit einbauen kann?!
Das hier ist der code mit dem ich die sucheinträge für den normalbetrieb eingebaut habe:
Code: Alles auswählen
#########################################################################################
##
## MOD Titel: Neues Feld im Postingbereich
## MOD Version: 1.4.2 (phpBB 2.0.5 - 2.0.10)
## optionaler Teil: Suche nach Extrainformation 1.0.3 (nur phpBB 2.0.10)
## Autor: Acid
##
## Beschreibung: Mit dieser Erweiterung kann man nach der Extrainformation suchen.
## Aufgrund einiger Änderungen in der functions_search.php (2.0.10),
## funktioniert die folgende Anleitung nur mit phpBB 2.0.10.
##
## Dateien zu ändern: 6
## language/lang_german/lang_main.php
## includes/functions_post.php
## includes/functions_search.php
## search.php
## viewtopic.php
## templates/xxx/search_body.tpl
##
#########################################################################################
##
## Notizen:
## Vor jeglichen Änderungen an Datenbank/Dateien sollten dieser gesichert werden.
##
## Wenn man mehr als ein neues Feld dem Postingbereich hinzugefügt hat, muss man folgende
## Schritte duplizieren und dabei jeweils die Bezeichnungen anpassen (auf Schreibweise
## achten, wie z.B. '$extra', '$topic_extra' oder 'TOPIC_EXTRA' etc.).
##
#########################################################################################
##
## Versionen:
##
## 1.0.3 - Code in functions_search.php angepasst (nur mit 2.0.10 kompatibel)
## 1.0.2 - Code fehlte bzw. war fehlerhaft (wenn man nur nach Extrainformation
## suchen wollte, farbliche Markierung der Suchergebnisse)
## 1.0.1 - angezeigte Extrainformation wird farblich markiert
## 1.0 - optionalen Teil hinzugefügt
##
#########################################################################################
#
#-----[ SQL ]-------------------------------------------
#
# Folgender Query muss über phpmyadmin ausgeführt werden (Prefix anpassen)..
ALTER TABLE phpbb_search_wordmatch ADD extra_match TINYINT(1) default '0' NOT NULL;
# ..wenn man mehrere Felder hinzufügt/ändert, muss man den obigen Query duplizieren und
# den Feldnamen "extra_match" anpassen.
#
#########################################################################################
#
#-----[ ÖFFNEN ]------------------------------------------
#
# language/lang_german/lang_main.php
#
#-----[ FINDE ]---------------------------------------------------
#
$lang['Search_title_msg'] = 'Titel und Text durchsuchen';
#
#-----[ MIT FOLGENDEM ERSETZEN ]---------------------------------------------------
#
$lang['Search_title_msg'] = 'Titel und Text durchsuchen';
$lang['Search_extra_only'] = 'Nur Extrainformation suchen';
#
#-----[ ÖFFNEN ]------------------------------------------
#
# includes/functions_post.php
#
#-----[ FINDE ]---------------------------------------------------
#
add_search_words('single', $post_id, stripslashes($post_message), stripslashes($post_subject));
#
#-----[ MIT FOLGENDEM ERSETZEN ]---------------------------------------------------
#
add_search_words('single', $post_id, stripslashes($post_message), stripslashes($post_subject), stripslashes($post_extra));
#
#-----[ ÖFFNEN ]------------------------------------------
#
# includes/functions_search.php
#
#-----[ FINDE ]---------------------------------------------------
#
function add_search_words($mode, $post_id, $post_text, $post_title = '')
{
global $db, $phpbb_root_path, $board_config, $lang;
$stopword_array = @file($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . "/search_stopwords.txt");
$synonym_array = @file($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . "/search_synonyms.txt");
$search_raw_words = array();
$search_raw_words['text'] = split_words(clean_words('post', $post_text, $stopword_array, $synonym_array));
$search_raw_words['title'] = split_words(clean_words('post', $post_title, $stopword_array, $synonym_array));
#
#-----[ MIT FOLGENDEM ERSETZEN ]---------------------------------------------------
#
function add_search_words($mode, $post_id, $post_text, $post_title = '', $post_extra = '')
{
global $db, $phpbb_root_path, $board_config, $lang;
$stopword_array = @file($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . "/search_stopwords.txt");
$synonym_array = @file($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . "/search_synonyms.txt");
$search_raw_words = array();
$search_raw_words['text'] = split_words(clean_words('post', $post_text, $stopword_array, $synonym_array));
$search_raw_words['title'] = split_words(clean_words('post', $post_title, $stopword_array, $synonym_array));
$search_raw_words['extra'] = split_words(clean_words('post', $post_extra, $stopword_array, $synonym_array));
#
#-----[ FINDE ]---------------------------------------------------
#
$title_match = ( $word_in == 'title' ) ? 1 : 0;
if ( $match_sql != '' )
{
$sql = "INSERT INTO " . SEARCH_MATCH_TABLE . " (post_id, word_id, title_match)
SELECT $post_id, word_id, $title_match
#
#-----[ MIT FOLGENDEM ERSETZEN ]---------------------------------------------------
#
$title_match = ( $word_in == 'title' ) ? 1 : 0;
$extra_match = ( $word_in == 'extra' ) ? 1 : 0;
if ( $match_sql != '' )
{
$sql = "INSERT INTO " . SEARCH_MATCH_TABLE . " (post_id, word_id, title_match, extra_match)
SELECT $post_id, word_id, $title_match, $extra_match
#
#-----[ ÖFFNEN ]------------------------------------------
#
# search.php
#
#-----[ FINDE ]---------------------------------------------------
#
$search_fields = ( $HTTP_POST_VARS['search_fields'] == 'all' ) ? 1 : 0;
#
#-----[ MIT FOLGENDEM ERSETZEN ]---------------------------------------------------
#
if( $HTTP_POST_VARS['search_fields'] == 'all' )
{
$search_fields = '1';
}
else if( $HTTP_POST_VARS['search_fields'] == 'msgonly' )
{
$search_fields = '0';
}
else if( $HTTP_POST_VARS['search_fields'] == 'extra' )
{
$search_fields = '2';
}
#
#-----[ FINDE ]---------------------------------------------------
#
$sql = "SELECT m.post_id
FROM " . SEARCH_WORD_TABLE . " w, " . SEARCH_MATCH_TABLE . " m
WHERE w.word_text LIKE '$match_word'
AND m.word_id = w.word_id
AND w.word_common <> 1
$search_msg_only";
#
#-----[ MIT FOLGENDEM ERSETZEN ]---------------------------------------------------
#
if( $search_fields == '0' )
{
$search_match = 'w.word_text LIKE \''. $match_word .'\' AND m.title_match = 0 AND m.extra_match = 0';
}
else if( $search_fields == '1' )
{
$search_match = 'w.word_text LIKE \''. $match_word .'\'';
}
else if( $search_fields == '2' )
{
$search_match = 'w.word_text LIKE \''. $match_word .'\' AND m.title_match = 0 AND m.extra_match = 1';
}
$sql = "SELECT m.post_id
FROM ". SEARCH_WORD_TABLE ." w, ". SEARCH_MATCH_TABLE ." m
WHERE ". $search_match ." AND m.word_id = w.word_id AND w.word_common <> 1";
#
#-----[ FINDE ]---------------------------------------------------
#
$search_msg_only = ( $search_fields ) ? "OR post_subject LIKE '$match_word'" : '';
$sql = "SELECT post_id
FROM " . POSTS_TEXT_TABLE . "
WHERE post_text LIKE '$match_word'
$search_msg_only";
#
#-----[ MIT FOLGENDEM ERSETZEN ]---------------------------------------------------
#
if( $search_fields == '0' )
{
$search_match = 'post_text LIKE \''. $match_word .'\'';
}
else if( $search_fields == '1' )
{
$search_match = 'post_text LIKE \''. $match_word .'\' OR post_subject LIKE \''. $match_word .'\'';
}
else if( $search_fields == '2' )
{
$search_match = 'post_text LIKE \''. $match_word .'\' OR post_extra LIKE \''. $match_word .'\'';
}
$sql = "SELECT post_id FROM ". POSTS_TEXT_TABLE ." WHERE ". $search_match;
#
#-----[ FINDE ]---------------------------------------------------
#
$message = preg_replace($highlight_match, '<span style="color:#' . $theme['fontcolor3'] . '"><b>\1</b></span>', $message);
#
#-----[ DARUNTER EINFÜGEN (oberhalb der abschliessenden Klammer) ]---------------------------------------------------
#
$post_extra = preg_replace($highlight_match, '<span style="color:#' . $theme['fontcolor3'] . '"><b>\1</b></span>', $post_extra);
#
#-----[ FINDE ]---------------------------------------------------
#
'L_SEARCH_MESSAGE_ONLY' => $lang['Search_msg_only'],
#
#-----[ DARUNTER EINFÜGEN ]---------------------------------------------------
#
'L_SEARCH_EXTRA_ONLY' => $lang['Search_extra_only'],
#
#-----[ ÖFFNEN ]------------------------------------------
#
# viewtopic.php
#
#-----[ FINDE ]---------------------------------------------------
#
$message = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "preg_replace('#\b(" . $highlight_match . ")\b#i', '<span style=\"color:#" . $theme['fontcolor3'] . "\"><b>\\\\1</b></span>', '\\0')", '>' . $message . '<'), 1, -1));
#
#-----[ DARUNTER EINFÜGEN ]---------------------------------------------------
#
$post_extra = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "preg_replace('#\b(" . $highlight_match . ")\b#i', '<span style=\"color:#" . $theme['fontcolor3'] . "\"><b>\\\\1</b></span>', '\\0')", '>' . $post_extra . '<'), 1, -1));
#
#-----[ ÖFFNEN ]------------------------------------------
#
# templates/xxx/search_body.tpl
#
#-----[ FINDE ]---------------------------------------------------
#
{L_SEARCH_MESSAGE_ONLY}
#
#-----[ DANACH EINFÜGEN (vor </span>) ]---------------------------------------------------
#
<br /><input type="radio" name="search_fields" value="extra" /> {L_SEARCH_EXTRA_ONLY}
#########################################################################################
#########################################################################################
#########################################################################################