Suchformular Resultatseite
Verfasst: Do 25. Okt 2007, 10:25
Hallo zusammen,
Ich möchte die Resultatseite meine Suchmaske anpassen. Momentan wird Titel und Inhalt (ersten paar 100 Zeichen) angezeigt. Ich möchte nun aber, dass unterhalb auch noch der Link eingeblendet wird (http://www...). Kann mir jemand helfen wie ich dies machen kann?
sollte dann so aussehen
Titel der Webpage
Dies ist der Inhaltstext mit seinen 200 Zeichen.
http://www.contendio.org/seite
eingabe
ausgabe
Ich möchte die Resultatseite meine Suchmaske anpassen. Momentan wird Titel und Inhalt (ersten paar 100 Zeichen) angezeigt. Ich möchte nun aber, dass unterhalb auch noch der Link eingeblendet wird (http://www...). Kann mir jemand helfen wie ich dies machen kann?
sollte dann so aussehen
Titel der Webpage
Dies ist der Inhaltstext mit seinen 200 Zeichen.
http://www.contendio.org/seite
eingabe
Code: Alles auswählen
$linktarget = "CMS_VALUE[1]";
$extratext = "CMS_VALUE[2]";
if($linktarget == "") {
$linktarget = "_self";
}
if($extratext == "") {
$extratext = 0;
}
?>
<table>
<tr>
<td>Linktarget</td>
<td>
<select name="CMS_VAR[1]">
<option value="_self"<? if(strcmp("_self", $linktarget) == 0) echo " selected"; ?>>gleiches Fenster (_self)</option>
<option value="_new"<? if(strcmp("_new", $linktarget) == 0) echo " selected"; ?>>neues Fenster (_new)</option>
</select>
</td>
</tr>
<tr>
<td>Zusätzlicher Text zum Artikellink</td>
<td>
<select name="CMS_VAR[2]">
<option value="0"<? if($extratext == 0) echo " selected"; ?>>kein zusätzlicher Text</option>
<option value="1"<? if($extratext == 1) echo " selected"; ?>>Artikelkommentar</option>
<option value="2"<? if($extratext == 2) echo " selected"; ?>>Anfang des Artikeltextes</option>
</select>
</td>
</tr>
</table>
<?
Code: Alles auswählen
<?php
//$linkziel = "front_content.php?idcat=15";
$linkziel = $auth->url();
$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");
$extratextLength = 200;
$suchtext = $_POST["suchtext"];
?>
<form name="suche" action="<?= $linkziel ?>" method="post">
<table>
<tr>
<td><span style="font-size: 15px">Suche </span></td>
<td><input name="suchtext" type="text" size="20" value="<?= $suchtext ?>"></td>
<td><input name="submit" type="submit" value="Go"></td>
</tr>
</table>
</form>
<?php
$linktarget = "CMS_VALUE[1]";
$extratext = "CMS_VALUE[2]";
/* DB Instances */
$db = new DB_Contenido;
$db2 = new DB_Contenido;
/* Template Instance */
$tpl = new Template;
if($suchtext != "") {
while(ereg(' ', $suchtext)) {
$suchtext = ereg_replace(' ', ' ', $suchtext);
}
$suchliste = explode(" ", strtolower($suchtext));
$suchliste = array_diff($suchliste, $ignore_konj, $ignore_art, $ignore);
$suchtext = trim(implode(" ", $suchliste));
if($verknuepfung == "oder") {
$suchregexp = "(" . str_replace(" ", ")|(", $suchtext) . ")";
$s = ereg_replace("ü", "%FC", strtolower($suchtext));
$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 " .
"FROM " .
$cfg["tab"]["art_lang"] . " AS A, " .
$cfg["tab"]["cat_art"] . " AS B, " .
$cfg["tab"]["cat"] . " AS C, " .
$cfg["tab"]["content"] . " AS D " .
"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' " .
"AND (D.value REGEXP '" . $suchregexp . "' " .
"OR A.title REGEXP '" . $suchregexp . "' " .
"OR A.summary REGEXP '" . $suchregexp . "')";
} // end if($verkuepfung)
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 " .
"FROM " .
$cfg["tab"]["art_lang"] . " AS A, " .
$cfg["tab"]["cat_art"] . " AS B, " .
$cfg["tab"]["cat"] . " AS C, " .
$cfg["tab"]["content"]." AS D " .
"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 . "')";
} // end while
reset($suchliste);
} // end else($verknuepfung)
$db->query($sql);
if($db->num_rows() != 0){
while($db->next_record()) {
if ($auth->auth["uid"] == "nobody"){
$sql2 = "SELECT " .
"public " .
"FROM " .
$cfg["tab"]["cat_lang"] . " " .
"WHERE " .
"idcat = '" . $db->f("idcat") . "'";
$db2->query($sql2);
if($db2->next_record()) {
if($db2->f("public") == 0) {
continue;
} // end if(public)
} // end if(next_record)
} // end if(auth nobody)
$num = 0 + $db->f("sideid");
$results[$num][link] = "front_content.php?" .
"client=" . $client .
"&lang=" . $lang .
"&idcat=" . $db->f("idcat") .
"&idart=" . $db->f("idart");
$results[$num][title] = $db->f("title");
//anzuzeigenden Text ermitteln
switch($extratext) {
case 0:
$results[$num][text] = "";
break;
case 1:
$results[$num][text] = $db->f("comment");
break;
case 2:
$results[$num][text] = capiStrTrimSentence(strip_tags(urldecode($db->f("content"))), $extratextLength) . "...";
break;
} // end switch
while(list($key, $val) = each($suchliste)) {
$hits[$num] += substr_count(strtolower(strip_tags(urldecode($db->f("title")))), $val) +
substr_count(strtolower(strip_tags(urldecode($db->f("comment")))), $val) +
substr_count(strtolower(strip_tags(urldecode($db->f("content")))), $val);
} // end while
reset($suchliste);
} // end while(next_record)
if(count($hits) > 0) {
//anzahl hits speichern
$anzahlhits = count($hits);
$hits = array_values($hits);
$results = array_values($results);
array_multisort ($results, SORT_DESC, SORT_NUMERIC, $hits, SORT_DESC, SORT_NUMERIC);
} // end if(count hits)
} // end if(num_rows)
//Ausgabe-----------------
/* Start Output buffer */
ob_start();
if(count($hits) > 0) {
$tpl->reset();
$tpl->set('s', 'SUCHTEXT', $suchtext);
$tpl->set('s', 'TREFFER', $anzahlhits);
for($i = 0; $i < count($hits); $i++) {
$tpl->set('d', 'ARTIKELNAME', $results[$i][title]);
$tpl->set('d', 'TARGET', $linktarget);
$tpl->set('d', 'HREF', $results[$i][link]);
$tpl->set('d', 'TEXT', $results[$i][text]);
$tpl->next();
}
$tpl->generate('templates/search_found.html');
} // end if(count hits)
else {
$tpl->reset();
$tpl->set('s', 'SUCHTEXT', $suchtext);
$tpl->generate('templates/search_notfound.html');
} // end else (count hits)
} // end if(suchtext)
/* Read out buffer */
$html = ob_get_contents();
/* Clean buffer */
ob_end_clean();
/* Output buffer-contents */
echo $html;
?>