Seite 1 von 1

volltextsuche durchsucht alle (offline) kategorien!?!

Verfasst: Mo 12. Jan 2004, 09:58
von axel s.
hallo zusammen,

ich habe eine frage zu dem modul volltextsuche v.1.2.

ein beispiel:
ich habe eine kategorie die "offline" geschaltet ist.
in dieser Kategorie ist ein artikel online und nicht als startartikel geschaltet (dieser verlinkte artikel muss online sein, da er als druckbare version vorliegen soll. liegt als orginal in einer anderen kategorie!)
über die suchfunktion wir jetzt dieser artikel aus der "offline kategorie" angezeigt!!
warum?
besteht die möglichkeit über eine voreinstellung die zu durchsuchenden kategorien einzuschränken (als vorgabe -> eingabe).

axel

Verfasst: Mo 12. Jan 2004, 11:24
von PickPay
Du musst wohl in der SQL-Abfrage irgendwo noch ein WHERE online=1 oder so einbauen.

Verfasst: Mo 12. Jan 2004, 11:43
von axel s.
das habe ich!!!

... wie gesagt kategorie ist off und der artikel darin ist on.

Verfasst: Mo 12. Jan 2004, 11:51
von PickPay
Ich habe mal das Modul heruntergeladen (Version 1.11, wo hast du 1.2 her?) und der Query etwas überarbeitet:

Code: Alles auswählen

	$sql = "SELECT
	         A.title AS title,
	         A.idart AS idart,
	         A.summary AS comment,
	         B.idcat AS idcat,
	         C.parentid AS parentid,
	         D.value AS content,
	         A.idartlang AS sideid 
	       FROM 
	        " . $cfg["tab"]["art_lang"] . " AS A, 
	        " . $cfg["tab"]["cat_art"] . " AS B, 
	        " . $cfg["tab"]["cat"] . " AS C, 
	        " . $cfg["tab"]["content"] . " AS D 
	        " . $cfg["tab"]["cat_lang"] . " AS E
	       WHERE 
	        A.idart=B.idart AND 
	        C.idcat=E.idcat AND 
	        E.public=1 AND 
	        A.idartlang=D.idartlang AND 
	        B.idcat=C.idcat AND 
	        C.idclient='$client' AND 
	        idlang='$lang' AND
	        online='1' AND 
	         (
	          D.value REGEXP '$suchregexp' OR 
	          A.title REGEXP '$suchregexp' OR 
	          A.summary REGEXP '$suchregexp'
	         )
	        ; 
	       ";
Allerdings habe ich die Sache nicht getestet, sondern lediglich noch eine Verknüpfung mir der Tabelle con_cat_lang erstellt, wo das Feld 'public' den Wert für Offline/Online enthält. Zudem wird nicht getestet, ob die übergeordneten Kategorien auch online sind. Das müsste man wohl in eine weitere Abfrage auslagern...

Verfasst: Mo 12. Jan 2004, 13:15
von axel s.
ich nochmal,

habe es eingebaut aber nicht public sonder visible auslesen lassen.

das ist die ausgabekompl:
--------------------------------------------------
<?php

echo '<form name="suche" method="POST" action="front_content.php?idcatart=4">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="text"><div align="right">Suchbegriff:&nbsp;<input type="text" size="15" style="text-align: left; font-family: Verdana,arial,helvetica; font-size: 11px; background-color: #FFFFFF; color: #E72900; border: 1 solid #DEAD73" name="suche" value="'.$suche.'" class="Input">&nbsp;<input type="image" src="upload/zoo/find.gif"></div></td>
</tr></table></center> </FO'.'RM>';
if($suche){
echo '<table width="100%" border="0" cellspacing="0" cellpadding="0" class="text">';
$ignore_konj = array("und","oder","als","wenn","auch","wo","wie");
$ignore_art = array("der","die","das","ein","eine");
$ignore = array("ich","du","er","sie","es","wir","ihr","sie");
$suche = trim($suche);
$suchliste = explode(" ",strtolower($suche));
$suchliste = array_diff ($suchliste, $ignore_konj, $ignore_art, $ignore);
$suche = trim(implode(" ",$suchliste));
if($verknuepfung=="oder"){
$suchregexp = "(".str_replace(" ",")|(",$suche).")";
$s=ereg_replace("ü", "%FC",strtolower($suche));
$s=ereg_replace("ä", "%E4",$s);
$s=ereg_replace("ö", "%F6",$s);
$suchregexp .= "|$s";
$sql = "SELECT A.title AS title,A.idart AS idart,A.summary AS comment,B.idcat AS idcat,D.value AS content,A.idartlang AS sideid ";
$sql .= "FROM ".$cfg["tab"]["art_lang"]." AS A, ".$cfg["tab"]["cat_art"]." AS B, ".$cfg["tab"]["cat"]." AS C, ".$cfg["tab"]["content"]." AS D ".$cfg["tab"]["cat_lang"]." AS E ";
$sql .= "WHERE A.idart=B.idart AND C.idcat=E.idcat AND E.visible=1 AND A.idartlang=D.idartlang AND B.idcat=C.idcat AND C.idclient='$client' AND idlang='$lang' AND online='1'";
$sql .= " AND (D.value REGEXP '".$suchregexp."' OR A.title REGEXP '".$suchregexp."' OR A.summary REGEXP '".$suchregexp."')";
} else {
$sql = "SELECT A.title AS title,A.idart AS idart,A.summary AS comment,B.idcat AS idcat,D.value AS content,A.idartlang AS sideid ";
$sql .= "FROM ".$cfg["tab"]["art_lang"]." AS A, ".$cfg["tab"]["cat_art"]." AS B, ".$cfg["tab"]["cat"]." AS C, ".$cfg["tab"]["content"]." AS D ";
$sql .= "WHERE A.idart=B.idart AND A.idartlang=D.idartlang AND B.idcat=C.idcat AND C.idclient='$client' AND idlang='$lang' AND online='1'";
while(list($key, $val) = each($suchliste)) {
$suchregexp = "(".str_replace(" ",")|(",$val).")";
$s=ereg_replace("ü", "%FC",strtolower($val));
$s=ereg_replace("ä", "%E4",$s);
$s=ereg_replace("ö", "%F6",$s);
$suchregexp .= "|$s";
$sql .= " AND (D.value REGEXP '".$suchregexp."' OR A.title REGEXP '".$suchregexp."' OR A.summary REGEXP '".$suchregexp."')";
} reset($suchliste);
}
$db->query($sql);
if ($db->num_rows() != 0){
for ($i=0; $i<$db->num_rows(); $i++) {
$db->next_record();
if ($auth->auth["uid"] == "nobody"){
$sql2 = "SELECT public FROM ".$cfg["tab"]["cat_lang"]." WHERE idcat='".$db->f("idcat")."'";
$db2 = new DB_Contenido; $db2->query($sql2); $db2->next_record();
if($db2->f("public") == 0)continue;
};
$num = 0 + $db->f("sideid");
$results[$num][link] = "front_content.php?client=$client&la"."ng=$lang&idcat=".$db->f("idcat")."&idart=".$db->f("idart")."";
$results[$num][title] = $db->f("title");
switch ("CMS_VALUE[2]") {
case 0: $results[$num][text] = "";break;
case 1: $results[$num][text] = $db->f("comment");break;
case 2: $results[$num][text] .= substr(strip_tags(urldecode($db->f("content"))),0,100)."...";
};
while(list($key, $val) = each($suchliste)) {
$hits[$num] += substr_count(strip_tags(urldecode(strtolower($db->f("title")))), $val) +
substr_count(strtolower(strip_tags(urldecode($db->f("comment")))), $val) +
substr_count(strtolower(strip_tags(urldecode($db->f("content")))), $val);
// echo $num.': '.$val.'='.$hits[$num].$db->f("content").'<br>';
}; reset($suchliste);
};
if(count($hits) > 0){
echo '<tr><td class="zooEins">Suchergebnis:
<br><BR></td></tr>';
$hits = array_values($hits);
$results = array_values($results);
array_multisort ($results, SORT_DESC, SORT_NUMERIC, $hits, SORT_DESC, SORT_NUMERIC);
for ($i=0; $i<count($hits); $i++){
echo "<tr><td align=left><p><a href=\"".$results[$i][link]."\"";
if("CMS_VALUE[3]"){echo "TARGET=\"CMS_VALUE[3]\" ";};
echo "><img src=\"upload/zoo/pf4.gif\" width=\"10\" height=\"15\" border=\"0\" align=\"absmiddle\">".$results[$i][title]."</a> ";
echo $results[$i][text]." <a href=\"".$results[$i][link]."\"";
if("CMS_VALUE[3]"){echo "TARGET=\"CMS_VALUE[3]\" ";};
echo "></a></p></td></tr>";
};
} else { echo "<tr><td align=left><p><b>Keine passenden Seiten gefunden</b></p></td></tr>"; };
} else { echo "<tr><td align=left><p><b>Keine passenden Seiten gefunden</b></p></td></tr>"; };
echo '</table>';
}
?>
-----------------------------------------------------------------------------

aber leider werden die offline kategorien immer noch ausgelesen!

Verfasst: Di 13. Jan 2004, 11:04
von axel s.
...ich habe den fehler im folgenden bereich gefunden:

----------------------------
.......
$sql2 = "SELECT visible FROM ".$cfg["tab"]["cat_lang"]." WHERE idcat='".$db->f("idcat")."'";
$db2 = new DB_Contenido; $db2->query($sql2); $db2->next_record();
if($db2->f("visible") == 0) continue;
-------------------------------------

ich habe public durch visible ersetzt.
visible zeigt an ob die kategorie on oder offline ist.