back to Modules

Search

What are these options?

Reindex All Content -- Goes through all of the content and participating modules and reindexes the content. This might need to be done after a module is freshly installed.

Stop Words -- Industry term for "words that don't get searched on". These are generally filled with a list of common words so that search queries will ignore common words in a multiple word phrase.

Use Word Stemming (English Only) -- Stemming is the process of removing suffixes from words intelligently before a search is done. So that "search", "searches" and "searching" would all count as the same word in the search.

How to change template for Search

Notice: This part is intended mainly fo newbies. If HTML and CSS are well known things for you, then this is probably nothing new for you.

Often you have search form styled in the template, that you are adapting for CMSMS. So, when you change it to {search}, you will likely find, that it doesn't look very well.

Image 1: Initial design of search form in template

For this example, I work with search form, which initially looked like Image 1. If you are curious, what "Hledat" means, it is "Search". Code for this form looked like that:

<div id="search">
 <form id="searchform" method="get" action="" name="searchform">
  <div>
   <input type="text" name="s" id="s" size="10" /><br />
   <input class="submit" type="submit" value="Hledat »" />
  </div>
 </form>
</div>

If you replace it in your template with something like:

<div id="search">{search}</div>

...you will get this in your page source:

<div id="search">
 <form id="m3moduleform_1" method="get" action="index.php">
  <div class="hidden">
   <input type="hidden" name="mact" value="Search,m3,dosearch,0" />
   <input type="hidden" name="m3returnid" value="62" />
  </div>
  <label for="m3searchinput">
  Hledat
  </label>
  : 
  <input type="text" name="m3searchinput" id="m3searchinput" value="" size="20" maxlength="50" 
onfocus="if(this.value==this.defaultValue) this.value='';" onblur="if(this.value=='') 
this.value=this.defaultValue;" />
  <input name="submit" value="Vyhledat" type="submit" />
  <input type="hidden" name="m3origreturnid" value="15" />
 </form>
</div>
Image 2: Unstyled search form is not very nice...

As you can see on Image 2, the unstyled search form doesn't look very great, so we have to change something. There are two ways to achieve this:

  1. You can change Search form template. This is somewhat problematic, because you can't alter class and id parameters, needed for CSS design, directly in CMSMS admin interface. Instead, it involves work directly in Search module source code. By using this technique, you are taking risk that your changes will be overwritten by new release of the module.
  2. You can change names of your CSS ids and classes to reflect those of chosen by module. By using this technique, you are taking risk that your changes will not correspond names in newer release of module.

For this article, I take the second. So open your CSS style, where you have settings for search form (It is located under Layout > Stylesheet) and start editing (you can optionally create separate stylesheet for Search, which may be handy later). You may also need to change template in Search module admin interface.

In my case, apart from changing the id for the text input field and class for submit (in my case, I had to alter submit field width too), I had to change search form template to:

{$startform}
{$inputbox}<input name="submit" class="submit" value="{$submittext}»" type="submit" />
{if isset($hidden)}{$hidden}{/if}
{$endform}

Then, my search form looks like in the first picture.

Search Cloud

Src: http://forum.cmsmadesimple.org/index.php/topic,26742.0.html

Put this code in an UDT search_cloud:

global $gCms;
$db = &$gCms->db;
$count = 0;

$q = "SELECT word, count FROM ".cms_db_prefix()."module_search_words ORDER BY count Limit 0,30";

$dbresult = $db->Execute( $q );

if( !$dbresult )
{
    echo 'DB error: '. $db->ErrorMsg()."<br/>";
}

$search_cloud = array();
$peak = 0;
$low = 0;

while ($dbresult && $dbqueryresultrow = $dbresult->FetchRow())
{
    $cloud_item = new StdClass;
    $cloud_item->word = $dbqueryresultrow[word];

    if ($dbqueryresultrow[count] >= $peak) {$peak = $dbqueryresultrow[count];}
    if ($dbqueryresultrow[count] <= $low) {$low = $dbqueryresultrow[count];}

    $cloud_item->count = $dbqueryresultrow[count];
    $cloud_item->class = ' ';

    $count++;
    $search_cloud[] = $cloud_item;
}

foreach ($search_cloud as $item) {
    $thisitem = $item->count;

    $hitrate = $thisitem / $peak;
    if ($hitrate >= 0.8)
    {
        $item->class= '100';
    }

    if (($hitrate >= 0.6) AND ($hitrate < 0.8))
    {
        $item->class= '80';
    }

    if (($hitrate >= 0.4) AND ($hitrate < 0.6))
    {
        $item->class= '60';
    }

    if (($hitrate >= 0.2) AND ($hitrate < 0.4))
    {
        $item->class= '40';
    }

    if ($hitrate < 0.2)
    {
        $item->class= '20';
    }
}
// Sort words alphabetically
sort($search_cloud);

//Send results to Smarty
$smarty = &$gCms->GetSmarty();
$smarty->assign(search_cloud, $search_cloud);

Use this in your template/page... (remove the line break in the link!)

<!-- START of Search Cloud -->
 <div id="cloud">
   {search_cloud}
   
   {foreach from=$search_cloud item=cloud_item} 
   
     <span class="c{$cloud_item->class}">
<a href="index.php?mact=Search%2Ccntnt01%2Cdosearch%2C0&cntnt01returnid=33&cntnt01searchinput={$cloud_item->word}
&cntnt01origreturnid=15"
title="Click here to start a search for {$cloud_item->word}" rel="nofollow">{$cloud_item->word}</a>
	</span>
  
  {/foreach}
 </div>
<!-- END of Search Cloud -->

Use this CSS for formating (for example):

#cloud span.c100 {font-size: 30px;}
#cloud span.c80 {font-size: 27px;}
#cloud span.c60 {font-size: 21px;}
#cloud span.c40 {font-size: 18px;}
#cloud span.c20 {font-size: 15px;}

Simplified Search Setup - Nov 30, 2010

I found the above a little confusing and not sure what goes where (what's the 'cloud' all abourt???) - here's my simple solution:

1. Go to Extensions - Search - I already had Search installed. Go to the Search Template and save any code and then "Reset Default". Same with the "Result Template" - save any code and restore defaults.

2. Then go to Content - Blocks - Header - and add this code:

<div id="search">{search resultpage="search-results"}</div>

These two steps worked for me. I'm using CMS Made Simple 1.8.2 "Toliara"


back to Modules


This page in: English - Deutsch - Español - Français - Italiano - Lietuvių - Nederlands - Norsk - Polski - Česky - Русский - Svenska - Tiếng Việt - عربي - 日本語 简体中文

User Handbook/Admin Panel/Extensions/Search

From CMSMS

Arvixe - A CMSMS Partner