Re: search module?
Posted: Thu Jul 14, 2005 11:26 pm
Has anyone any news on a search module yet? just need this and my site is finished.
Thanks
Thanks
Content management as it is meant to be
https://forum.cmsmadesimple.org/
Code: Select all
function.search.php
Code: Select all
<?php
function smarty_CMS_function_search($params, &$smarty) {
$domain = $_SERVER['SERVER_NAME'];
$buttonText = 'Search Site';
if (!empty($params['buttonText']))
$buttonText = $params['buttonText'];
return '<form method="get" action="index.php">
<input type="hidden" name="page" value="searchResults">
<input type="hidden" name="module" value="Search">
<input type="hidden" name="template_demo" value="phpdig.html">
<input type="hidden" name="refine" value="0">
<input type="hidden" name="result_page" value="search.php">
<input type="text" id="query_string" name="query_string" size="15" maxlength="50" alue="">
<input type="submit" id="buttonSearch" value="'.$buttonText.'">
</form>';
}
function smarty_CMS_help_function_search() {
}
function smarty_CMS_about_function_search() {
}
?>
I don't know what to do with this now.Warning: Smarty error: unable to read resource: "db:searchResults" in /usr/export/www/vhosts/funnetwork/hosting/madmcal/cmsmadesimple/lib/smarty/Smarty.class.php on line 1088
Code: Select all
<?php
function smarty_cms_function_pisearch($params, &$smarty) {
global $gCms;
$config = $gCms->config;
$db = $gCms->db;
$result ="";
$search="";
if (isset($_GET["pisearch"])) $search = $_GET["pisearch"];
if ($search)
{
$search2=trim($search);
$search_ar=explode(" ",$search2);
$dbresult = $db->Execute("SELECT * FROM `".cms_db_prefix()."content` WHERE active = '1' AND type ='content' ORDER BY hierarchy");
if ($dbresult)
{
$first=true;
foreach ($dbresult as $row)
{
reset($search_ar);
$current=current($search_ar);
$w=false;
if ($current<>false) $w=true;
$weiter=$current;
$dbr = $db->GetRow("SELECT * FROM ".cms_db_prefix()."content_props WHERE content_id='".$row['content_id']."'");
if ($dbr)
{
$text=strip_tags($dbr['content']);
$vowels = array(".", ",", ":", "(", ")", "[", "]", "=", ";", "?",'"',"/","#",'"',"§","$","€","!"," ");
$text = str_replace($vowels, " ", $text);
}
else
{
$w=false;
}
while ($w)
{
// use strpos with older php - versions. stripos searchs in a case-insensitive manner, strpos not
$pos=stripos($text,$weiter);
if ($pos)
{
if ($first)
{
$result .='<span class="pisearchresult">Die Suchbegriffe wurden in folgenden Seiten gefunden: -> Suchworte ('.$search.') :</span><br />';
$first=false;
}
$result .='<span class="pisearch"><a class="pisearchlink" href="'.$config['root_url'].'/index.php?'.$config["query_var"]."=".$row['content_id'].'">'.$row['menu_text'].'</a></span><br />';
$w=false;
}
else
{
$weiter=next($search_ar);
if ($weiter<>false) {$w=true;}else{$w=false;}
} // if pos
} // while
} //foreach
} // if dbresult
} // if search
return $result;
}
function smarty_cms_help_function_pisearch() {
?>
<p>You must set the plugintag in the template</p>
<p>Create an inputformular to get the word to search in the template. </p>
<p>
Change History:<br/>
None
</p>
<?php
}
function smarty_cms_about_function_pisearch() {
?>
<p>Author: Jan Czarnowski (Piratos) piratos@coftware.de</p>
<p>Version: 1.0</p>
<p>
Change History:<br/>
None
</p>
<?php
}
?>
Code: Select all
<form action="http://localhost/beta4/index.php" method="get"> <input type="text" value="" maxlength="50" size="15" name="pisearch" id="query_string" /> <input type="submit" value="Suchen" id="buttonSearch" /> </form>
I had a look and I must say that I'm very impressed about Sphider. Especially the possibilty to keep pages from being indexed (robot.txt, rel="nofollow" attribute in tags and even parts of pages (although that would require some coding by hand) and the output (with a part of the context around the searched word), makes this lightweight script a good solution IMHO.100rk wrote: It seems like everybody likes MySQL fulltext search - I am sorry, I don't.
I agree, there is some limits for search systems like PhpDig, Isearch etc (safe mode, time limit...), but there are also 'Made Simple' (lightweight) search systems under GPL licence - for example this one: http://www.cs.ioc.ee/~ando/sphider/. It could not be so hard create module 'around' this product - for person with little bit 'free' time, of course.