26

Re: search plugin

mvdkleijn wrote:

If you can show us what's in your layout, we might be able to help.

"old" site - 0.6.0 RC1 - belv.xlphp.net

Home Page - body
<h2>Web Site For You</h2>
<div id="mainText">&nbsp;Many business owners still operate without a web presence. Most of them will tell you they don't need a web site because their business is already going well. Then I remind them about the threat of losing business because they can not be reached on the web...</div>
<div id="mainPic" class="floatleft">
<div class="newsPic">
<div class="picStyle"><a href="<?php echo URL_PUBLIC; ?>"><img alt="#1" width="272" height="190" src="<?php echo URL_PUBLIC; ?>/public/themes/freelance/images/01.jpg" /></a></div>
</div>
<div class="newsPic">
<div class="picStyle"><a href="<?php echo URL_PUBLIC; ?>"><img alt="#2" width="272" height="190" src="<?php echo URL_PUBLIC; ?>public/themes/freelance/images/02.jpg" /></a></div>
</div>
<div class="newsPic">
<div class="picStyle"><a href="<?php echo URL_PUBLIC; ?>"><img alt="#3" width="272" height="190" src="<?php echo URL_PUBLIC; ?>public/themes/freelance/images/03.jpg" /></a></div>
</div>
<div class="newsPic">
<div class="picStyle"><a href="<?php echo URL_PUBLIC; ?>"><img alt="#4" width="272" height="190" src="<?php echo URL_PUBLIC; ?>public/themes/freelance/images/04.gif" /></a></div>
</div>
<div class="newsPic">
<div class="picStyle"><a href="<?php echo URL_PUBLIC; ?>"><img alt="#5" width="272" height="190" src="<?php echo URL_PUBLIC; ?>public/themes/freelance/images/05.gif" /></a></div>
</div>
<div class="newsPic">
<div class="picStyle"><a href="<?php echo URL_PUBLIC; ?>"><img alt="#6" width="272" height="190" src="<?php echo URL_PUBLIC; ?>public/themes/freelance/images/06.gif" /></a></div>
</div>
</div>
<p style="margin-left: 295px"><strong style="color: #4088b8">The website it is not luxury, it is means of advancement of your business!</strong> While having a web site is not an end all for marketing your business, it is something that modern consumers expect and will use if available. Potential customers expect businesses to keep up with the times and a website can help you do that. Expansion is another reason for a web site. Most small businesses cannot afford to expand significantly.With a well managed web site you can have a business presence that is world wide...
<p class="readmore"><a href="<?php echo URL_PUBLIC; ?>">Read more</a> &raquo;</p>
<h2>Software For You</h2>
<p>Are you looking for a WordPress theme version of this template? Or maybe a version that is ported for Textpattern, Etomite, MODx, Blogger or some other <a href="http://solucija.com/">great content management system</a> or blog engine? Then check out my <a href="http://andreasviklund.com/templates/themes">ports and themes page</a> to see if there are any version available that you can use. If you make a port yourself, please let me know so I can your version to the list.</p>
<p class="readmore"><a href="<?php echo URL_PUBLIC; ?>">Read more</a> &raquo;</p>
<p class="box"><strong>Note:</strong> Contact me at the email address valerib@012.net.il or call at 0545-237689. Just send me information about your business and what you have in mind and I will submit a complete proposal by email. There is no obligation. Thanks.
<a href="<?php echo URL_PUBLIC; ?>?price_estimate.php">Get a free price estimate</a> &raquo;</p>
Home Page – sidebar

<div id="searchframe">
<form action="/?search-results<?php echo URL_SUFFIX;?>#listing" method="post" id="searchbox">

<input type="text" name="search" id="search" value="<?php echo strip_tags($_POST['search']);?>" />
<input type="submit" name="searchsubmit" value="search" class="submit" /></form>

</div>

Search results

<a name="listing"></a>
<?php
if (isset($_POST['search'])){   
    $searchcriteria = $_POST['search'];
    if($searchcriteria != NULL && preg_match('#^[a-z0-9\x20]+$#i', $searchcriteria)){
        echo $this->includeSnippet('sitesearch');
    }else{
        echo "<p>Please input a search criteria.</p>";
    }
}
?>

Contact

<?php TB_Contactform('valerib@012.net.il', 'admin@belv.xlphp.net', 'Your message was sent successfully', 'Please allow up to 24 hours for a reply.');  ?>

Layout-main (for Home Page)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "[url]http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd[/url]">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

<head>
<title>Carmel Software - Freelance Web Designer and Database Developer in Haifa, Israel - <?php echo $this->title(); ?></title>

<meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8" />
<meta name="robots" content="index, follow" />
<meta name="description" content="<?php echo ($this->description() != '') ? $this->description() : 'Homepage Carmel Software'; ?>" />
<meta name="keywords" content="<?php echo ($this->keywords() != '') ? $this->keywords() : 'theme, graphique, css, template, frog'; ?>" />
<meta name="author" content="Carmel Software" />

<link rel="favourites icon" href="<?php echo URL_PUBLIC; ?>favicon.ico" />
<link rel="canonical" href="<?php echo $this->url(); ?>" />

<!--  CSS -->

<link rel="stylesheet" type="text/css" href="<?php echo URL_PUBLIC; ?>public/themes/freelance/style.css" title="800px css style" media="screen,projection" />
<link rel="stylesheet" type="text/css" href="<?php echo URL_PUBLIC; ?>public/themes/freelance/contact.css" title="contact_form css style" media="screen,projection" />
<!-- Javascript -->
                                     <script type="text/javascript" src="<?php echo URL_PUBLIC; ?>public/themes/freelance/js/jquery.js"></script>
        <script type="text/javascript" src="<?php echo URL_PUBLIC; ?>public/themes/freelance/js/jquery.innerfade.js"></script>
                                      <script type="text/javascript" src="<?php echo URL_PUBLIC; ?>public/themes/freelance/js/slide.js"></script> 

</head>
 
<body>
<noscript>     
<center><table border="0" style="height: 100%; width: 100%; right: 1%; left: 1%; background: #F5E391; position: fixed">
                                     <tr><td align="center">
<div style="position: fixed; font-size: 18px; z-index: 2; cursor: help; background: #F5E391; width: 480px; color: black; padding: 5px 5px 5px 5px; border: 1px solid; border-color: #000000; height: auto; text-align: left; left: 20%">
<span style="font: bold 20px Arial; color:#000000; background: #F5E391; vertical-align: middle">NO SCRIPT ERROR:</span><br /> 
     Sorry this site will not function properly without the use of scripts.
     The scripts are safe and will not harm your computer in anyway. 
     Adjust your settings to allow scripts for this site and reload the site.</div> 
          </td></tr></table></center> 

</noscript>



<div id="wrap">
 
<div id="header">
 
                      <p id="toplinks"> 
 
              <a href="<?php echo URL_PUBLIC; ?>?"><img src="<?php echo URL_PUBLIC; ?>public/themes/freelance/images/home.gif" alt="Home" /> Home</a> | 
 <a href="<?php echo BASE_URL; ?>sitemap"><img src="<?php echo URL_PUBLIC; ?>public/themes/freelance/images/sitemap.gif" alt="Sitemap" /> Sitemap</a> | 
 <a href="<?php echo URL_PUBLIC; ?>?contact.html"><img src="<?php echo URL_PUBLIC; ?>public/themes/freelance/images/contact.gif" alt="Contact" /> Contact</a>      

                     </p>
 
 
<h1><a href="<?php echo URL_PUBLIC; ?>">Carmel<span class="fade">  Software</span></a></h1>
<p id="slogan">software development and webdesign</p>

</div> <!--/Header-->
 

<!--main section-->
                       <div id="content">
                            <?php echo $this->content(); ?> 
                            <?php if ($this->hasContent('extended')) echo $this->content('extended'); ?> 
                      </div>
<!--/main section-->

<div id="sidebar">

<h2>Welcome!</h2>
<p>  My name is Valeri and I am freelance  software developer  and websites builder. Not matter where you are in the world, and who you are, I can help you to take your business online, 
I can help to solve your computer problems quickly and for a moderate payment...</p>
<p class="readmore"><a href="styles.html">Read more</a> &raquo;</p>  
 
<h2>Pages:</h2>
<ul>
<li><a href="#">About</a></li>
<li><a href="#">Site's Gallery</a></li>
<li><a href="#">Services:</a>
<ul>
<li><a href="#">Sites</a></li>
<li><a href="#">Software</a></li>
</ul></li>
<li><a href="#">Price estimate</a></li>
<li><a href="?contact.html">Contact</a></li>
<li><a class="hide" href="#header">Back to top</a></li>
</ul>
 

<h2>Links:</h2>
<ul class="links">
<li><a href="http://andreasviklund.com/templates/">Free templates</a></li>
<li><a href="http://www.onderhond.com/tools/ie6fixer/">IE6 CSS Fixer</a></li>
<li><a href="http://www.andybudd.com/archives/2006/10/7_habits_of_a_highly_successful_freelance_web_designer/">Andy Budd article</a></li>
<li><a href="http://www.flickr.com/">Flickr - Photo Sharing</a></li>
<li><a href="http://oswd.org">del.icio.us - bookmarks </a></li>
</ul>


<h2>Site Search:</h2>
<?php echo $this->content('sidebar', true); ?> 
</div>  <!--/sidebar-->


<!--footer-->

<div id="footer">
 
<p class="footer-left"><a href="#header">Back to top</a></p>
<p><a href="<?php echo URL_PUBLIC; ?>">Home</a> | <a href="#">About</a> | <a href="#">Services</a> | <a href="#">Portfolio</a> | 
<a href="<?php echo URL_PUBLIC; ?>?contact.html">Contact</a> | <a href="<?php echo URL_PUBLIC; ?>admin">Administrator</a> <br />
 Carmel Software &copy; 2009  | Thanks to <a href="http://andreasviklund.com/">Andreas Viklund</a> | Based on<a href="http://www.wolfcms.org" rel="external">  Wolf CMS</a> technology</p>

</div><!--/footer-->
 
</div>
</body>
</html> 

Layout-additional(for pages Contact, Seach results, etc)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "[url]http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd[/url]">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

<head>
<title>Carmel Software - Freelance Web Designer and Database Developer in Haifa, Israel - <?php echo $this->title(); ?></title>


<meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta name="robots" content="index, follow" />
<meta name="description" content="<?php echo ($this->description() != '') ? $this->description() : 'Homepage Carmel Software'; ?>" />
<meta name="keywords" content="<?php echo ($this->keywords() != '') ? $this->keywords() : 'theme, graphique, css, template, wolf,cms'; ?>" />
<meta name="author" content="Carmel Software" />

<link rel="favourites icon" href="<?php echo URL_PUBLIC; ?>favicon.ico" />


<!--  CSS -->

<link rel="stylesheet" type="text/css" href="<?php echo URL_PUBLIC; ?>public/themes/freelance/style.css" title="800px css style" media="screen,projection" />
<link rel="stylesheet" type="text/css" href="<?php echo URL_PUBLIC; ?>public/themes/freelance/contact.css" title="contact_form css style" media="screen,projection" />
<!-- Javascript -->
                                     <script type="text/javascript" src="<?php echo URL_PUBLIC; ?>public/themes/freelance/js/jquery.js"></script>
        <script type="text/javascript" src="<?php echo URL_PUBLIC; ?>public/themes/freelance/js/jquery.innerfade.js"></script>
                                      <script type="text/javascript" src="<?php echo URL_PUBLIC; ?>public/themes/freelance/js/slide.js"></script> 


</head>
 
<body>
<noscript>     
<center><table border="0" style="height: 100%; width: 100%; right: 1%; left: 1%; background: #F5E391; position: fixed">
                                     <tr><td align="center">
<div style="position: fixed; font-size: 18px; z-index: 2; cursor: help; background: #F5E391; width: 480px; color: black; padding: 5px 5px 5px 5px; border: 1px solid; border-color: #000000; height: auto; text-align: left; left: 20%">
<span style="font: bold 20px Arial; color:#000000; background: #F5E391; vertical-align: middle">NO SCRIPT ERROR:</span><br /> 
     Sorry this site will not function properly without the use of scripts.
     The scripts are safe and will not harm your computer in anyway. 
     Adjust your settings to allow scripts for this site and reload the site.</div> 
          </td></tr></table></center> 

</noscript>

<div id="wrap">
 
<div id="header">
 
                      <p id="toplinks"> 
 
              <a href="<?php echo URL_PUBLIC; ?>?"><img src="<?php echo URL_PUBLIC; ?>public/themes/freelance/images/home.gif" alt="Home" /> Home</a> | 
 <a href="<?php echo BASE_URL; ?>sitemap"><img src="<?php echo URL_PUBLIC; ?>public/themes/freelance/images/sitemap.gif" alt="Sitemap" /> Sitemap</a> | 
 <a href="<?php echo URL_PUBLIC; ?>?contact.html"><img src="<?php echo URL_PUBLIC; ?>public/themes/freelance/images/contact.gif" alt="Contact" /> Contact</a>      
                      </p>
 
 <div style="width=400px;">
<h1><a href="<?php echo URL_PUBLIC; ?>">Carmel<span class="fade">  Software</span></a></h1>
<p id="slogan">software development and webdesign</p></div>
 <div style="float:right;position:relative;top:-90px;display:inline">

<form action="/?search-results<?php echo URL_SUFFIX;?>#listing" method="post" id="searchbox">

        <table class="searchBox">
            <tr>
                <td>
                    <input type="text" name="search" size="20" value="<?php echo strip_tags($_POST['search']);?>" />
                    <input type="submit" name="searchsubmit" value="search" class="submit" />
                </td>
            </tr>
        </table>
</form></div></div>


<!--main section-->
                       <div id="content">
                            <?php echo $this->content(); ?> 
                            <?php if ($this->hasContent('extended')) echo $this->content('extended'); ?> 
                      </div>
<!--/main section-->

<!--footer-->

<div id="footer">
 
<p class="footer-left"><a href="#header">Back to top</a></p>
<p><a href="<?php echo URL_PUBLIC; ?>">Home</a> | <a href="#">About</a> | <a href="#">Services</a> | <a href="#">Portfolio</a> | 
<a href="<?php echo URL_PUBLIC; ?>?contact.html">Contact</a> | <a href="<?php echo URL_PUBLIC; ?>admin">Administrator</a> <br />
 Carmel Software &copy; 2009  | Thanks to <a href="http://andreasviklund.com/">Andreas Viklund</a> |  Based on<a href="http://www.wolfcms.org/" rel="external">  Wolf CMS</a> technology</p>

</div><!--/footer-->
 
</div>
</body>
</html> 
Snippets:

sitesearch

<?php
function is_in_array($str, $array) {
    return preg_grep('/^' . preg_quote($str, '/') . '$/i', $array);
}

function snippet_sitesearch($parent){
    $exclude = array("search-results");
    $mysearch = htmlentities($_POST['search']);
    if($parent->slug == "") {
        if(!in_array($parent->slug,$exclude)){
            $mylink = $parent->link();
            $mycrumb = $parent->breadcrumb;
            if(stristr($parent->content(),$mysearch) || stristr($parent->title(),$mysearch) || is_in_array($mysearch,$parent->tags())){
                $out .= '<li><strong><a href="/">'.$mycrumb.'</a></strong></li>';
            }
        }
    }
    $childs = $parent->children();
    foreach ($childs as $child) {
        if(!in_array($child->parent->slug,$exclude)){
            $myparent = snippet_sitesearch($child);
             $mylink = $child->link();
             $url_segments = explode('/', $child->url);
            $url_seg_count = count($url_segments);
            if($url_seg_count > 1){
                $mycrumb = ucfirst(str_replace('-',' ',$child->parent->breadcrumb)).' / '.$child->breadcrumb;
            } else {
                $mycrumb = $child->breadcrumb;
            }
            if(stristr($child->content(),$mysearch) || stristr($child->title(),$mysearch) || is_in_array($mysearch,$child->tags())){
                $out .= '<li><strong><a href="'.$child->url.URL_SUFFIX.'">'.$mycrumb.'</a></strong></li>';
            }
            $out .= snippet_sitesearch($child);
        }
    }
    $out = str_replace("<li><li>", "<li>", $out);
    $out = str_replace("</li></li>", "</li>", $out);
    return $out;
}
?>
<div id="listing">
<?php
$searchdata = "";
$searchdata .= snippet_sitesearch($this->find('/'));
$occurances = substr_count($searchdata,"<li>");
if($searchdata != NULL){
    if($occurances > 1){$results="results";}else{$results="result";}
    echo "<p>Search $results for: <strong>" . $_POST['search'] . "</strong></p>";
    echo "<ol>";
    echo $searchdata;
    echo "</ol>";
} else {
    echo "<p>Search result for: <strong>" . $_POST['search'] . "</strong></p>";
    echo "<p>No matching results were found.</p>";
}
?>
</div>

"new" site - 0.6.0 RC1b - belv.0fees.net

Home Page - body
<h2>Web Site For You</h2>
<div id="mainText">&nbsp;Many business owners still operate without a web presence. Most of them will tell you they don't need a web site because their business is already going well. Then I remind them about the threat of losing business because they can not be reached on the web...</div>
<div id="mainPic" class="floatleft">
<div class="newsPic">
<div class="picStyle"><a href="<?php echo URL_PUBLIC; ?>"><img alt="#1" width="272" height="190" src="<?php echo URL_PUBLIC; ?>/public/themes/freelance/images/01.jpg" /></a></div>
</div>
<div class="newsPic">
<div class="picStyle"><a href="<?php echo URL_PUBLIC; ?>"><img alt="#2" width="272" height="190" src="<?php echo URL_PUBLIC; ?>public/themes/freelance/images/02.jpg" /></a></div>
</div>
<div class="newsPic">
<div class="picStyle"><a href="<?php echo URL_PUBLIC; ?>"><img alt="#3" width="272" height="190" src="<?php echo URL_PUBLIC; ?>public/themes/freelance/images/03.jpg" /></a></div>
</div>
<div class="newsPic">
<div class="picStyle"><a href="<?php echo URL_PUBLIC; ?>"><img alt="#4" width="272" height="190" src="<?php echo URL_PUBLIC; ?>public/themes/freelance/images/04.gif" /></a></div>
</div>
<div class="newsPic">
<div class="picStyle"><a href="<?php echo URL_PUBLIC; ?>"><img alt="#5" width="272" height="190" src="<?php echo URL_PUBLIC; ?>public/themes/freelance/images/05.gif" /></a></div>
</div>
<div class="newsPic">
<div class="picStyle"><a href="<?php echo URL_PUBLIC; ?>"><img alt="#6" width="272" height="190" src="<?php echo URL_PUBLIC; ?>public/themes/freelance/images/06.gif" /></a></div>
</div>
</div>
<p style="margin-left: 295px"><strong style="color: #4088b8">The website it is not luxury, it is means of advancement of your business!</strong> While having a web site is not an end all for marketing your business, it is something that modern consumers expect and will use if available. Potential customers expect businesses to keep up with the times and a website can help you do that. Expansion is another reason for a web site. Most small businesses cannot afford to expand significantly.With a well managed web site you can have a business presence that is world wide...
<p class="readmore"><a href="<?php echo URL_PUBLIC; ?>">Read more</a> &raquo;</p>
<h2>Software For You</h2>
<p>Are you looking for a WordPress theme version of this template? Or maybe a version that is ported for Textpattern, Etomite, MODx, Blogger or some other <a href="http://solucija.com/">great content management system</a> or blog engine? Then check out my <a href="http://andreasviklund.com/templates/themes">ports and themes page</a> to see if there are any version available that you can use. If you make a port yourself, please let me know so I can your version to the list.</p>
<p class="readmore"><a href="<?php echo URL_PUBLIC; ?>">Read more</a> &raquo;</p>
<p class="box"><strong>Note:</strong> Contact me at the email address valerib@012.net.il or call at 0545-237689. Just send me information about your business and what you have in mind and I will submit a complete proposal by email. There is no obligation. Thanks.
<a href="<?php echo URL_PUBLIC; ?>?price_estimate.php">Get a free price estimate</a> &raquo;</p>
Home Page – sidebar

<div id="searchframe">
<form action="/?search-results<?php echo URL_SUFFIX;?>#listing" method="post" id="searchbox">
<input type="text" name="search" id="search" value="<?php echo strip_tags($_POST['search']);?>" />
<input type="submit" name="searchsubmit" value="search" class="submit" /></form>
</div>

Search results
<a name="listing"></a>
<?php
if (isset($_POST['search'])){   
    $searchcriteria = $_POST['search'];
         if($searchcriteria != NULL && preg_match('#^[a-z0-9\x20]+$#i', $searchcriteria)){
       
         echo $this->includeSnippet('sitesearch');
   
    }else{
        echo "<p>Please input a search criteria.</p>";
    }
}
?>

Contact
<?php TB_Contactform('valerib@012.net.il', 'admin@belv.0fees.net', 'Your message was sent successfully', 'Please allow up to 24 hours for a reply.');  ?>

Layout-main (for Home Page)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "[url]http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd[/url]">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

<head>
<title>Carmel Software - Freelance Web Designer and Database Developer in Haifa, Israel - <?php echo $this->title(); ?></title>

<meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8" />
<meta name="robots" content="index, follow" />
<meta name="description" content="<?php echo ($this->description() != '') ? $this->description() : 'Homepage Carmel Software'; ?>" />
<meta name="keywords" content="<?php echo ($this->keywords() != '') ? $this->keywords() : 'theme, graphique, css, template, frog'; ?>" />
<meta name="author" content="Carmel Software" />

<link rel="favourites icon" href="<?php echo URL_PUBLIC; ?>favicon.ico" />
<link rel="canonical" href="<?php echo $this->url(); ?>" />

<!--  CSS -->

<link rel="stylesheet" type="text/css" href="<?php echo URL_PUBLIC; ?>public/themes/freelance/style.css" title="800px css style" media="screen,projection" />
<link rel="stylesheet" type="text/css" href="<?php echo URL_PUBLIC; ?>public/themes/freelance/contact.css" title="contact_form css style" media="screen,projection" />
<!-- Javascript -->
                                     <script type="text/javascript" src="<?php echo URL_PUBLIC; ?>public/themes/freelance/js/jquery.js"></script>
        <script type="text/javascript" src="<?php echo URL_PUBLIC; ?>public/themes/freelance/js/jquery.innerfade.js"></script>
                                      <script type="text/javascript" src="<?php echo URL_PUBLIC; ?>public/themes/freelance/js/slide.js"></script> 

</head>
 
<body>
<!--begin:search\/\/-->
<noscript>     
<center><table border="0" style="height: 100%; width: 100%; right: 1%; left: 1%; background: #F5E391; position: fixed">
                                     <tr><td align="center">
<div style="position: fixed; font-size: 18px; z-index: 2; cursor: help; background: #F5E391; width: 480px; color: black; padding: 5px 5px 5px 5px; border: 1px solid; border-color: #000000; height: auto; text-align: left; left: 20%">
<span style="font: bold 20px Arial; color:#000000; background: #F5E391; vertical-align: middle">NO SCRIPT ERROR:</span><br /> 
     Sorry this site will not function properly without the use of scripts.
     The scripts are safe and will not harm your computer in anyway. 
     Adjust your settings to allow scripts for this site and reload the site.</div> 
          </td></tr></table></center> 

</noscript>

<div id="wrap">
 
<div id="header">
 
                      <p id="toplinks"> 
 
              <a href="<?php echo URL_PUBLIC; ?>?"><img src="<?php echo URL_PUBLIC; ?>public/themes/freelance/images/home.gif" alt="Home" /> Home</a> | 
 <a href="<?php echo BASE_URL; ?>sitemap"><img src="<?php echo URL_PUBLIC; ?>public/themes/freelance/images/sitemap.gif" alt="Sitemap" /> Sitemap</a> | 
 <a href="<?php echo URL_PUBLIC; ?>?contact.html"><img src="<?php echo URL_PUBLIC; ?>public/themes/freelance/images/contact.gif" alt="Contact" /> Contact</a>      

                     </p>
 
 <h1><a href="<?php echo URL_PUBLIC; ?>">Carmel<span class="fade">  Software</span></a></h1>
<p id="slogan">software development and webdesign</p>

</div> <!--/Header-->
 
<!--main section-->
                       <div id="content">
                            <?php echo $this->content(); ?> 
                            <?php if ($this->hasContent('extended')) echo $this->content('extended'); ?> 
                      </div>
<!--/main section-->

<div id="sidebar">

<h2>Welcome!</h2>
<p>  My name is Valeri and I am freelance  software developer  and websites builder. Not matter where you are in the world, and who you are, I can help you to take your business online, 
I can help to solve your computer problems quickly and for a moderate payment...</p>
<p class="readmore"><a href="styles.html">Read more</a> &raquo;</p>  
 
<h2>Pages:</h2>
<ul>
<li><a href="#">About</a></li>
<li><a href="#">Site's Gallery</a></li>
<li><a href="#">Services:</a>
<ul>
<li><a href="#">Sites</a></li>
<li><a href="#">Software</a></li>
</ul></li>
<li><a href="#">Price estimate</a></li>
<li><a href="?contact.html">Contact</a></li>
<li><a class="hide" href="#header">Back to top</a></li>
</ul>
 
<h2>Links:</h2>
<ul class="links">
<li><a href="http://andreasviklund.com/templates/">Free templates</a></li>
<li><a href="http://www.onderhond.com/tools/ie6fixer/">IE6 CSS Fixer</a></li>
<li><a href="http://www.andybudd.com/archives/2006/10/7_habits_of_a_highly_successful_freelance_web_designer/">Andy Budd article</a></li>
<li><a href="http://www.flickr.com/">Flickr - Photo Sharing</a></li>
<li><a href="http://oswd.org">del.icio.us - bookmarks </a></li>
</ul>

<h2>Site Search:</h2>
<?php echo $this->content('sidebar', true); ?> 
</div>  <!--/sidebar-->


<!--footer-->

<div id="footer">
 
<p class="footer-left"><a href="#header">Back to top</a></p>
<p><a href="<?php echo URL_PUBLIC; ?>">Home</a> | <a href="#">About</a> | <a href="#">Services</a> | <a href="#">Portfolio</a> | 
<a href="<?php echo URL_PUBLIC; ?>?contact.html">Contact</a> | <a href="<?php echo URL_PUBLIC; ?>admin">Administrator</a> <br />
 Carmel Software &copy; 2009  | Thanks to <a href="http://andreasviklund.com/">Andreas Viklund</a> | Based on<a href="http://www.wolfcms.org" rel="external">  Wolf CMS</a> technology</p>

</div><!--/footer-->
 
</div>
<!--end:search\/\/-->
</body>
</html>

Layout-additional(for pages Contact, Seach results, etc)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "[url]http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd[/url]">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Carmel Software - Freelance Web Designer and Database Developer in Haifa, Israel - <?php echo $this->title(); ?></title>

<meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta name="robots" content="index, follow" />
<meta name="description" content="<?php echo ($this->description() != '') ? $this->description() : 'Homepage Carmel Software'; ?>" />
<meta name="keywords" content="<?php echo ($this->keywords() != '') ? $this->keywords() : 'theme, graphique, css, template, wolf,cms'; ?>" />
<meta name="author" content="Carmel Software" />

<link rel="favourites icon" href="<?php echo URL_PUBLIC; ?>favicon.ico" />

<!--  CSS -->

<link rel="stylesheet" type="text/css" href="<?php echo URL_PUBLIC; ?>public/themes/freelance/style.css" title="800px css style" media="screen,projection" />
<link rel="stylesheet" type="text/css" href="<?php echo URL_PUBLIC; ?>public/themes/freelance/contact.css" title="contact_form css style" media="screen,projection" />
<!-- Javascript -->
                                     <script type="text/javascript" src="<?php echo URL_PUBLIC; ?>public/themes/freelance/js/jquery.js"></script>
        <script type="text/javascript" src="<?php echo URL_PUBLIC; ?>public/themes/freelance/js/jquery.innerfade.js"></script>
                                      <script type="text/javascript" src="<?php echo URL_PUBLIC; ?>public/themes/freelance/js/slide.js"></script> 

</head>
 
<body>
<!--begin:search\/\/-->
<noscript>     
<center><table border="0" style="height: 100%; width: 100%; right: 1%; left: 1%; background: #F5E391; position: fixed">
                                     <tr><td align="center">
<div style="position: fixed; font-size: 18px; z-index: 2; cursor: help; background: #F5E391; width: 480px; color: black; padding: 5px 5px 5px 5px; border: 1px solid; border-color: #000000; height: auto; text-align: left; left: 20%">
<span style="font: bold 20px Arial; color:#000000; background: #F5E391; vertical-align: middle">NO SCRIPT ERROR:</span><br /> 
     Sorry this site will not function properly without the use of scripts.
     The scripts are safe and will not harm your computer in anyway. 
     Adjust your settings to allow scripts for this site and reload the site.</div> 
          </td></tr></table></center> 

</noscript>

<div id="wrap">
 
<div id="header">
 
                      <p id="toplinks"> 
 
              <a href="<?php echo URL_PUBLIC; ?>?"><img src="<?php echo URL_PUBLIC; ?>public/themes/freelance/images/home.gif" alt="Home" /> Home</a> | 
 <a href="<?php echo BASE_URL; ?>sitemap"><img src="<?php echo URL_PUBLIC; ?>public/themes/freelance/images/sitemap.gif" alt="Sitemap" /> Sitemap</a> | 
 <a href="<?php echo URL_PUBLIC; ?>?contact.html"><img src="<?php echo URL_PUBLIC; ?>public/themes/freelance/images/contact.gif" alt="Contact" /> Contact</a>      
                      </p>
 
 <div style="width=400px;">
<h1><a href="<?php echo URL_PUBLIC; ?>">Carmel<span class="fade">  Software</span></a></h1>
<p id="slogan">software development and webdesign</p></div>
 <div style="float:right;position:relative;top:-90px;display:inline">

<form action="/?search-results<?php echo URL_SUFFIX;?>#listing" method="post" id="searchbox">

        <table class="searchBox">
            <tr>
                <td>
                    <input type="text" name="search" size="20" value="<?php echo strip_tags($_POST['search']);?>" />
                    <input type="submit" name="searchsubmit" value="search" class="submit" />
                </td>
            </tr>
        </table>
</form></div></div>


<!--main section-->
                       <div id="content">
                            <?php echo $this->content(); ?> 
                            <?php if ($this->hasContent('extended')) echo $this->content('extended'); ?> 
                      </div>
<!--/main section-->


<!--footer-->

<div id="footer">
 
<p class="footer-left"><a href="#header">Back to top</a></p>
<p><a href="<?php echo URL_PUBLIC; ?>">Home</a> | <a href="#">About</a> | <a href="#">Services</a> | <a href="#">Portfolio</a> | 
<a href="<?php echo URL_PUBLIC; ?>?contact.html">Contact</a> | <a href="<?php echo URL_PUBLIC; ?>admin">Administrator</a> <br />
 Carmel Software &copy; 2009  | Thanks to <a href="http://andreasviklund.com/">Andreas Viklund</a> |  Based on<a href="http://www.wolfcms.org/" rel="external">  Wolf CMS</a> technology</p>

</div><!--/footer-->
 
</div>
<!--end:search\/\/-->
</body>
</html>
Snippets:

sitesearch

<?php
function is_in_array($str, $array) {
    return preg_grep('/^' . preg_quote($str, '/') . '$/i', $array);
}

function snippet_sitesearch($parent){
    $exclude = array("search-results");
    $mysearch = htmlentities($_POST['search']);
    if($parent->slug == "") {
        if(!in_array($parent->slug,$exclude)){
            $mylink = $parent->link();
            $mycrumb = $parent->breadcrumb;
            if(stristr($parent->content(),$mysearch) || stristr($parent->title(),$mysearch) || is_in_array($mysearch,$parent->tags())){
                $out .= '<li><strong><a href="/">'.$mycrumb.'</a></strong></li>';
            }
        }
    }
    $childs = $parent->children();
    foreach ($childs as $child) {
        if(!in_array($child->parent->slug,$exclude)){
            $myparent = snippet_sitesearch($child);
             $mylink = $child->link();
             $url_segments = explode('/', $child->url);
            $url_seg_count = count($url_segments);
            if($url_seg_count > 1){
                $mycrumb = ucfirst(str_replace('-',' ',$child->parent->breadcrumb)).' / '.$child->breadcrumb;
            } else {
                $mycrumb = $child->breadcrumb;
            }
            if(stristr($child->content(),$mysearch) || stristr($child->title(),$mysearch) || is_in_array($mysearch,$child->tags())){
                $out .= '<li><strong><a href="'.$child->url.URL_SUFFIX.'">'.$mycrumb.'</a></strong></li>';
            }
            $out .= snippet_sitesearch($child);
        }
    }
    $out = str_replace("<li><li>", "<li>", $out);
    $out = str_replace("</li></li>", "</li>", $out);
    return $out;
}
?>
<div id="listing">
<?php
$searchdata = "";
$searchdata .= snippet_sitesearch($this->find('/'));
$occurances = substr_count($searchdata,"<li>");
if($searchdata != NULL){
    if($occurances > 1){$results="results";}else{$results="result";}
    echo "<p>Search $results for: <strong>" . $_POST['search'] . "</strong></p>";
    echo "<ol>";
    echo $searchdata;
    echo "</ol>";
} else {
    echo "<p>Search result for: <strong>" . $_POST['search'] . "</strong></p>";
    echo "<p>No matching results were found.</p>";
}
?>
</div>

Thanks in advance!

Thumbs up

27

Re: search plugin

That's a lot of code, belv. wink

This reminds me of a time when the older (simpler!) version of this "site_search" snippet stopped working on one of my sites. Eventually, I got it working again by removing all the list code, and  simply using "print" with BR's to return the found link. That line looks like this (still!):

if (stristr($mychild.$child->content(),$mysearch) || stristr($mychild.$child->content('extended'),$mysearch)) {
print '+ '.$child->link().'<br />';
}

I don't have time to suggest revised code for you, but it might be something worth trying?

Hopefully we can get it working (again!) with you. (And at least you know it *should* work!)

28

Re: search plugin

P.s. Just to make sure, I did a "diff" on your two site-search snippets, and they are (as you know!) identical. There must be some difference either with included scripts or hosting variations that is making the new site a problem.

FWIW, this snippet was working fine for me on a site ... until it stopped working with no changes I know of! Now, maybe I introduced some analytics or something and didn't notice, or maybe the hosts changed some minor thing in the PHP set up. Whatever it was, changing from the concatenated "$out" statements in a list, to the single output (as above) got it working again.

Re: search plugin

Hmmm.... can't really seem to replicate this. I did get a couple of errors regarding:

- the POST value for "search" not being set
- $out not being defined

those were easily fixed though.

Wolf CMS founder and lead developer
Please always check the Support forums and Wiki before asking. (My Ohloh account.)
Like Wolf CMS? Consider making a financial contribution.

30

Re: search plugin

mvdkleijn wrote:

Hmmm.... can't really seem to replicate this. I did get a couple of errors regarding:

- the POST value for "search" not being set
- $out not being defined

those were easily fixed though.

Additional information:

Experiment #1.
In page Search results   before line

echo $this->includeSnippet('sitesearch');

I have added 2 lines:
      echo("searchcriteria=");
        echo($searchcriteria);

After  search  word "port" I have received
page without results of search and without FOOTER, but with a line
"searchcriteria=port"
In my opinion, it proves that the POST value has been sent.

Experiment #2.
Inside snippet (the first line after  <php ?     I have added a line
echo("The print inside snippet sitesearch");
and has received the same result, as in "Experiment #1", but with the additional text
"The print inside snippet sitesearch"
It proves that function includeSnippet works.
There are the problems connected with snippet.
Probably to find/make another snippet easier?

Thumbs up

31

Re: search plugin

belv wrote:

There are the problems connected with snippet.
Probably to find/make another snippet easier?

I'm not so sure! Until there is a full-blown mySQL-based search plugin, BlueWolf's system would be hard to beat, IMO. Did you try an experiment based on my suggestions in post #27 (and see #28, too!)? If not, maybe you could try that; and if you did try, do let us know the results.

32

Re: search plugin

David, I has not absolutely understood, what you suggest to make? Give your variant of snippet, plz...

Thumbs up

Re: search plugin

This search stuff works just fine, no problem at all getting it to work.
Though I do have one question:
how can I have a list of words that should be ignored during a search?

Last edited by Fortron (2010-01-26 13:19)

Re: search plugin

Fortron wrote:

how can I have a list of words that should be ignored during a search?

That would just require an additional array, like the one presently used for excluding pages to be searched ... I need to think twice about adding more features right now however, as this search method is a little resource intensive as it is. To add too many other parameters is only going to add to that, until a proper database search solution emurges.

Thumbs up

Re: search plugin

BlueWolf wrote:
Fortron wrote:

how can I have a list of words that should be ignored during a search?

That would just require an additional array, like the one presently used for excluding pages to be searched ... I need to think twice about adding more features right now however, as this search method is a little resource intensive as it is. To add too many other parameters is only going to add to that, until a proper database search solution emurges.

Well the only thing that doesn't seem to work at all is the "excluding pages" part.
It doesn't work on the website where I have it set up, it still includes the excluded page in the search results.
Any idea's what might be the problem?

Last edited by Fortron (2010-01-30 22:22)

Re: search plugin

Here's what I use, it prevents direct access to the search page.
It might be of interest to someone.

<?php
if (!isset($_POST['search'])) {
    header('HTTP/1.0 403 Forbidden');
    $host = $_SERVER['HTTP_HOST'];
    header("Location: http://$host");
    exit;
} else {   
    $searchcriteria = $_POST['search'];
         if($searchcriteria != NULL && preg_match('#^[a-z0-9\x20]+$#i', $searchcriteria)){
         if (!$this->includeSnippet('zoekfunctie')) echo '<p>De zoekfunctie is momenteel niet beschikbaar</p>' . PHP_EOL;
    }else{
        echo "<p>Vult u a.u.b. een zoekopdracht in.</p>";
    }
}
?>

37

Re: search plugin

hello,
i use the search code  of this post, but  it find any result in comments ?
if somebody has a beginning of an answer ...
Thanks you

do one thing at a time, but do it well, making it available to as many, and finally listen, correct, repeat ....

Thumbs up

Re: search plugin

Fortron wrote:

Here's what I use, it prevents direct access to the search page.
It might be of interest to someone.

Very handy option, Fortron.

Thumbs up

Re: search plugin

sukoi wrote:

i use the search code  of this post, but  it find any result in comments ?
if somebody has a beginning of an answer

I honestly have never used this feature, not even back in the days of Frog CMS ... anyone else care to make a suggestion!?

Last edited by BlueWolf (2010-02-26 19:15)

Thumbs up

Re: search plugin

belv wrote:

Search of English words goes well, however it is impossible to find Russian words

I've been looking into this but as php does not offer this by default I am sticking with the default english alpha-numeric support. If anyone else wants to write a regex that offers UTF-8 support then by all means please do so, but for now, I feel the current regex is more secure.

On a different topic, I am putting the last touches into a relevance rating system for the search results ... does anybody have some other suggestions?

Last edited by BlueWolf (2010-03-01 21:41)

Thumbs up

41

Re: search plugin

Hello,

I have used this beautiful search engine called Orca
http://www.greywyvern.com/orca in the past with
static html sites with no problem.
How can I make it function within wolfcms?

I already tried putting the 3 includes it needs in a layout
but it always returns 0 results for any search, when it
should find some. What am I doing wrong?

This is a powerful multi-language full utf-8 engine
and I think it's gpl lisenced!

edit: Also tried some things with the file_get_contents
trick I saw in another post, but no success either.

Please help!

Last edited by sokyl (2010-03-06 08:33)

Thumbs up

42

Re: search plugin

sokyl wrote:

I have used this beautiful search engine called Orca
... How can I make it function within wolfcms?

This is a powerful multi-language full utf-8 engine
and I think it's gpl lisenced!

Hi sokyl - welcome to the Wolf forums!

Have you tried to "map" Orca search into Wolf's plugin API? It probably needs something like that to get working fulliy.

I know that Andrew (plugin dev extraordinaire) used Orca in the past, but the site that used it before (http://www.avfestival.co.uk/) doesn't seem to have a search option at the moment, so I don't know what happened there.

That means it should be do-able ... so I'm just holding out hope for you until someone knowledgeable comes by!

43

Re: search plugin

David wrote:

Have you tried to "map" Orca search into Wolf's plugin API? It probably needs something like that to get working fulliy.
...
That means it should be do-able ... so I'm just holding out hope for you until someone knowledgeable comes by!

Hi David,
I also do believe that the solution should be in the plugin API because something is missing with the other possible solutions I tried.
The problem is that I'm a begginer around MVCs philosophy and also very new to the way Wolf/Frog functions, in order to make a plugin myself.

Thumbs up

44

Re: search plugin

Orca's a pretty powerful search engine - I may take a look at the license and see how easy it may be to adapt to Wolf as a plugin.

It's a bit more than mapping as it has its own set of interfaces for administration configuration and will need to sit nicely within Wolf's plugin API but I'm fairly confident it can be done.

No promises on time though, we've got a lot of other bits to do first then I'll get on to it smile

Thumbs up

Re: search plugin

andrew wrote:

we've got a lot of other bits to do first then I'll get on to it smile

Please give prio on "the other bits" wink

Wolf CMS founder and lead developer
Please always check the Support forums and Wiki before asking. (My Ohloh account.)
Like Wolf CMS? Consider making a financial contribution.

46

Re: search plugin

@BlueWolf (if you're watching!) -

It turns out that a change in the way includeSnippet() works now creates a little problem for this search routine.

That change means that you can test for the existence of a snippet, so it now returns boolean 0 or 1. The way the Search page is coded means that if you run a search, you will always get a mystery "1" showing up! In the code given in post #4 (page 1 of this thread), second code block ("Search results" page), line 6 now reads:

        echo $this->includeSnippet('sitesearch');

But, in fact, you don't need the "echo", and it's the "echo" that will produce the mysterious "1" for post-revision 172 Wolf installs! Just changing it to:

        $this->includeSnippet('sitesearch');

fixes the problem.

FULL KUDOS to our fearless leader, Martijn cool, for fixing this one. I had stared at the code far too long and couldn't work out where that "1" was coming from. Martijn spotted the superfluous "echo", and the mystery was solved!

Re: search plugin

David wrote:

@BlueWolf (if you're watching!)

I'm watching, David.

Thanks for the headsup, I will make a note of that.

I've made alot of changes to the search routine since my last post. It has since got mixed with some other plugins I'm working on and relies on some functions that need seperating, but overall I have upgraded my search feature to now be analytics-friendly, have basic ranking and feature some usability and accessibility tweaks.

Now I just need to seperate all this out so as to make it more portable.

Thumbs up

48

Re: search plugin

Hi everyone,

I'm new to Wolf and found it whilst revisiting Frog CMS from an old bookmark.

I've just set up Wolf 0.6.0 and just got BlueWolf's search working great, my version doesn't like any characters in the search term though.

For example:

Searching  '  hello world  ' is ok

Searching  '  hello-world  ' doesn't work

I've followed BlueWolf's code from post 4, any ideas? I apologise in advance if this is a known issue and I've missed it reading through this posts.

Thanks.

Thumbs up

49

Re: search plugin

Forest wrote:

Searching  '  hello-world  ' doesn't work

Hi Forest - welcome to the Wolf Forums!

In post #4, above, you see this line in the 2nd code block:

if($searchcriteria != NULL && preg_match('#^[a-z0-9\x20]+$#i', $searchcriteria)){

The "preg_match" is only allowing alpha-numerics through. This is a security measure to make sure you don't get code injections.  (I think! wink )  You need to adjust that filter if you want to allow hyphens through. However one might do that!

50

Re: search plugin

Hi David, thanks for pointing me in the right direction!

I'll be leaving it as is, I was thinking it was my install on localhost that's all.

Cheers.

Last edited by Forest (2010-05-11 17:58)

Thumbs up