Jump to content
Steven Koontz

How to make a Simple Search Module that searches title, content & custom fields

Recommended Posts

Steven Koontz

Some of us prefer the functionality of the Simple Search that is on the list pages over the keyword search from the Advanced Search Module. So here is how to make a module with the functionality of the Simple Search.

 

Navigate to one of your list pages and view the source code (Ctrl+U). Find the Simple Search code. Should look something like this:

 

<!--  BEGIN SEARCH CONTROLS  -->
   
    <div class="jr_listSearch">
	    <form name="jr_simpleSearchForm" action="" method="post">
		    <input size="20" type="text" name="data[keywords]" class="jrText" value="Search" onblur="if(this.value=='') this.value='Search';" onfocus="if(this.value=='Search') this.value='';" />
               <button onclick="jQuery(this).parents('form:eq(0)').attr('action',s2AjaxUri).submit();" class="jrButton">Buscar</button>
		     <a href="http://yourdomain.com/your-advanced-search-menu-url" >Advanced Search</a>                                <input type="hidden" name="data[simple_search]" value="1" />
		    <input type="hidden" name="data[dir]" value="2" />
		    <input type="hidden" name="data[controller]" value="search" />
		    <input type="hidden" name="data[action]" value="_process" />
		    <input type="hidden" name="data[menu_id]" value="232" />					
		    
				<input type="hidden" name="data[cat]" value="" />

	    </form>
    </div>
<!--  END SEARCH CONTROLS  -->

 

Copy and paste this code into a Custom HTML Module.

 

You might have to tweak the HTML a bit to get the layout how you want it, depending on your template and where you are inserting the module.

 

That's it!

 

Notes:

 

Most likely, all of the parameters below will already be set according to your search preferences you set in JReviews Configuration, 'Search' tab. But I include them here for clarification.

 

This code limits results to a specific directory:

<input type="hidden" name="data[dir]" value="2" />

 

This code limits results to the current category:

<input type="hidden" name="data[cat]" value="" />

 

Erase both of those lines to search across all listings, or change the values to limit results to the directory/category IDs you desire.

 

 

 

You might have to paste the URL of one of your Advanced Search Menus here:

<a href="http://yourdomain.com/your-advanced-search-menu-url" >Advanced Search</a>

 

Here you have to input the ID of the menu you want to use on the results page, or leave the value blank to use the current page menu ID:

<input type="hidden" name="data[menu_id]" value="232" />

 

 

You can change the code in /jreviews/controllers/categories_controller.php, function search if you want to show results that include one or more of multiple keyword searches, instead of only showing results containing the entire text string.

 

WARNING: these results are not ordered by relevance, so changing this code will likely result in very broad search results on most sites.

 

Change:      

$simplesearch_query_type = 'all'; // any|all

 

to:

 

$simplesearch_query_type = 'any'; // any|all

Share this post


Link to post
lies

This section is only visible with a valid subscription. If you have a valid subscription, please login.

Share this post


Link to post
Steven Koontz

This section is only visible with a valid subscription. If you have a valid subscription, please login.

Share this post


Link to post
gsantos

This section is only visible with a valid subscription. If you have a valid subscription, please login.

Share this post


Link to post
Steven Koontz

This section is only visible with a valid subscription. If you have a valid subscription, please login.

Share this post


Link to post
gsantos

This section is only visible with a valid subscription. If you have a valid subscription, please login.

Share this post


Link to post
Steven Koontz

This section is only visible with a valid subscription. If you have a valid subscription, please login.

Share this post


Link to post
gsantos

This section is only visible with a valid subscription. If you have a valid subscription, please login.

Share this post


Link to post
Steven Koontz

This section is only visible with a valid subscription. If you have a valid subscription, please login.

Share this post


Link to post
gsantos

This section is only visible with a valid subscription. If you have a valid subscription, please login.

Share this post


Link to post
Alejandro

This section is only visible with a valid subscription. If you have a valid subscription, please login.

Share this post


Link to post
gsantos

This section is only visible with a valid subscription. If you have a valid subscription, please login.

Share this post


Link to post
Alejandro

This section is only visible with a valid subscription. If you have a valid subscription, please login.

Share this post


Link to post
andragor

This section is only visible with a valid subscription. If you have a valid subscription, please login.

Share this post


Link to post
Nathalie Bünger

This section is only visible with a valid subscription. If you have a valid subscription, please login.

Share this post


Link to post
Alejandro

This section is only visible with a valid subscription. If you have a valid subscription, please login.

Share this post


Link to post
MovieTheatreReviews.com

This section is only visible with a valid subscription. If you have a valid subscription, please login.

Share this post


Link to post

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Please refer to our Privacy Policy.