nutze modul "Volltextsuche mit Highlighting und UND-/ODER-Verknuepfung"
http://www.contenido.org/forum/viewtopi ... sc&start=0
habe auch hier schon meine frage gestellt, aber leider konnte mir bisher keiner helfen.
habe auf einer site verschiedene "bäume" (quasi als neue hauptnavi mit ca. 20 unterkategorien, die als eigenständige homepages agieren).
jetzt möchte ich aber nicht die ganze datenbank durchsuchen lassen, sondern nur einen bestimmten bereich, also hier einen "baum".
ist das prinzipiell möglich? wie könnte ich die suche einschränken?
habe schon mal probiert die sql-abfrage mit
AND CATART.is_start = '132' (132 für meinen fall)
in der
$whereClause = " " .
irgendwie einzubauen, allerdings ohne erfolg. das ist wohl nicht der ansatz


hier der code des moduls
Code: Alles auswählen
<?php
/***********************************************
* CONTENIDO MODUL - OUTPUT
*
* Modulname : w3concepts.search.v1.2
* Author : Andreas Kummer
* Copyright : mumprecht & kummer w3concepts
* Created : 2004-12-29
* Modified : 2005-07-27
* Modified by : Christa Tabara
* conFlakes-Teil herausgenommen
* ***********************************************/
class Search {
function Search() {
// Globale Variablen in Klassenkontext aufnehmen
$this->getGlobals();
// Übergabeparameter in Klassenkontext aufnehmen
$this->importParameters();
// Datenbankverbindung herstellen
$this->db = new DB_Contenido;
// Suchmaske ausgeben
echo $this->getSearchMask();
// Suche vornehmen
if (!empty($this->post['searchEntry'])) {
$this->doSearch();
$this->showResults();
}
}
function getGlobals() {
global $auth;
$this->classGlobal['auth'] = $auth;
}
function importParameters() {
$this->get = array ();
if (!empty ($_GET))
foreach ($_GET as $key => $value) {
$this->get[$key] = $value;
}
$this->post = array ();
if (!empty ($_GET))
foreach ($_GET as $key => $value) {
$this->post[$key] = $value;
}
}
function getSearchMask() {
if (array_key_exists('searchEntry',$this->post)) {
$searchEntry = $this->post['searchEntry'];
} else {
$searchEntry = '';
}
$kat = "$_GET[idcat]";
$sucheintrag = "&$_GET[searchEntry]";
if ("$_GET[logical]" != "")
{
$suchlogik = "&logical=$_GET[logical]";
}
$returnvalue = " <div>
<form method=\"get\" action=\"front_content.php?idcat=$kat"."$sucheintrag"."$suchlogik\">\n
<div><input type=\"hidden\" name=\"idcat\" value=\"33\"/>\n<input type='hidden' name='lang' value='1'>\n<input type='hidden' name='client' value='1'></div>\n";
$returnvalue .= "<div><input style=\"border:solid 1px #999; padding:3px;\" type=\"text\" name=\"searchEntry\" size=\"30\" value=\"$searchEntry\"/>";
$returnvalue .= ' <input type="submit" name="doSearch" value="Suche starten" /></div>';
if (!empty($this->post['logical']) && $this->post['logical'] == 'or') {
$returnvalue .= '<div style="margin-top:10px; margin-bottom:30px;"><fieldset><legend>Logische Verknüpfung der Suchbegriffe</legend><div style="margin-bottom:5px; margin-top:5px;"><input style="vertical-align:bottom;" type="radio" name="logical" value="and" /> UND (alle Begriffe sind vorhanden)</div>';
$returnvalue .= '<div><input style="vertical-align:bottom;" type="radio" name="logical" value="or" checked="checked" /> ODER (ein Begriff oder mehrere sind vorhanden)</div></fieldset></div>';
} else {
$returnvalue .= '<div style="margin-top:10px; margin-bottom:30px;font-size: 12px;"><fieldset><legend>Logische Verknüpfung der Suchbegriffe</legend><div style="margin-bottom:5px; margin-top:5px;"><input style="vertical-align:bottom;" type="radio" name="logical" value="and" checked="checked" /> UND (alle Begriffe sind vorhanden)</div>';
$returnvalue .= '<div><input style="vertical-align:bottom;" type="radio" name="logical" value="or" /> ODER (ein Begriff oder mehrere sind vorhanden)</div></fieldset></div>';
}
$returnvalue .= '</form>';
return $returnvalue;
}
function doSearch() {
global $cfg, $client, $lang;
$sql = "" .
"SELECT " .
" a.title, " .
" a.idart, " .
" a.summary, " .
" a.idartlang, " .
" b.idcat, " .
" count(*) AS ordervalue, " .
" a.lastmodified " .
"FROM {$cfg['tab']['art_lang']} AS a " .
"LEFT JOIN {$cfg['tab']['cat_art']} AS b ON a.idart = b.idart " .
"LEFT JOIN {$cfg['tab']['cat']} AS c ON b.idcat = c.idcat " .
"LEFT JOIN {$cfg['tab']['content']} AS d ON a.idartlang = d.idartlang " .
"WHERE " .
" c.idclient = $client " .
" AND a.idlang = $lang " .
" AND a.online = 1 ";
$searchString = str_replace('*','.*',trim(strtolower($this->post['searchEntry'])));
if ($this->post['logical'] == 'or') {
// Suchbegriffe sind logisch ODER-verknüpft
$regExpression = "(".str_replace(" ", ")|(", $searchString).")";
$s = ereg_replace("ü", "%FC", $regExpression);
$s = ereg_replace("ä", "%E4", $s);
$s = ereg_replace("ö", "%F6", $s);
$regExpression .= " | $s";
$whereClause = " " .
"AND (" .
" d.value REGEXP '{$regExpression}' " .
" OR a.title REGEXP '{$regExpression}' " .
" OR a.summary REGEXP '{$regExpression}' " .
" OR d.value REGEXP '{$s}' " .
" OR a.title REGEXP '{$s}' " .
" OR a.summary REGEXP '{$s}' " .
" ) ";
} else {
// Suchbegriffe sind logisch UND-verknüpft
$searchStrings = explode(' ',$searchString);
$whereClause = '';
foreach ($searchStrings as $search) {
$regExpression = "($search)";
$s = ereg_replace("ü", "%FC", $regExpression);
$s = ereg_replace("ä", "%E4", $s);
$s = ereg_replace("ö", "%F6", $s);
// $regExpression .= " | $s";
$whereClause .= " " .
"AND (" .
" d.value REGEXP '{$regExpression}' " .
" OR a.title REGEXP '{$regExpression}' " .
" OR a.summary REGEXP '{$regExpression}' " .
" OR d.value REGEXP '{$s}' " .
" OR a.title REGEXP '{$s}' " .
" OR a.summary REGEXP '{$s}' " .
" ) ";
}
}
$sql = $sql.$whereClause;
$sql = $sql." " .
"GROUP BY " .
" a.title, " .
" a.idart, " .
" a.summary, " .
" a.idartlang, " .
" b.idcat, " .
" a.lastmodified " .
"ORDER BY " .
" ordervalue DESC";
$this->db->query($sql);
$this->searchResults = array();
while ($this->db->next_record()) {
$this->searchResults[$this->db->f('idartlang')] = array('idart'=>$this->db->f('idart'),'idcat'=>$this->db->f('idcat'),'title'=>$this->db->f('title'),'summary'=>$this->db->f('summary'),'lastmodified'=>$this->db->f('lastmodified'));
}
}
function showResults() {
global $sess, $cfgClient, $client, $lang;
// Ausgabe der Suchresultate
if (!empty($this->searchResults)) {
// Ausgabe der Resultate
$counter = 0;
foreach ($this->searchResults as $result) {
$counter++;
$suchwort = $this->post['searchEntry'];
$link = $link = $sess->url($cfgClient[$client]['path']['htmlpath']."front_content.php?client=$client&lang=$lang&idcat={$result['idcat']}&idart={$result['idart']}&suchwort=$suchwort");
echo '<div style="margin-bottom:15px;">';
echo "<div style=\"margin-bottom:5px;font-size: 12px;\"><a href=\"$link\"><span style=\"font-weight:bold;\">{$result['title']}</span></a></div>";
echo "<div style=\"margin-bottom:5px;font-size: 12px;\">{$result['summary']}</div>";
echo "<div style=\"font-size: 10px;\">Letztmals aktualisiert: {$result['lastmodified']}</div>";
echo '</div>';
}
} else {
// Ausgabe der Meldung, dass keine Seiten gefunden worden sind.
echo '<div style="font-size: 12px;">Die Suche ergab keine Resultate. Versuchen Sie es bitte mit anderen Suchbegriffen.</div>';
}
}
}
$Search = new Search();
?>
sabsab