Advanced Search

By Helmut_pdorfHelmut_pdorf

Description

There is a CSI Function available from Keneth tsangktsangk which allows additinal selections and functions on a search button:

  • users are presented with a UI to set search filters for category, author and title
  • admins can set default values for each of these values in addition,
  • admins are also able to enforce these default values (thereby restricting search results to the designated default filters) plus,
  • admins may hide these filter fields from users to remove confusion
  • admins are able to set the label of the search button..
Notice: this page is included from http://community.wikidot.com/blog:advanced-search

Code

Hello Fellow Wikidotians,
Recently, I released the new Advanced Search CSI (cross-site include) - an easy to use extension to the current search module. This new include extends the current search module in a number of ways:

  • users are presented with a UI to set search filters for category, author and title
  • admins can set default values for each of these values
    • in addition, admins are also able to enforce these default values (thereby restricting search results to the designated default filters)
    • plus, admins may hide these filter fields from users to remove confusion
  • admins are able to set the label of the search button

"Now, that's all good", you may say. "So, how do you do it?"

Installing the new Advanced Search module is not advanced at all! I'll provide you with a couple of snippet examples for you to copy and edit to suit your needs. For each of these, simply copy the code displayed here and replace the Search Module in your wiki's search:site and voila! Let's begin:

"Simple" Advanced Search

"Simple" Advanced Search simply replaces the current search module with one with three extra filter fields for title, author and category.

[[include :csi:include:adv-search]]


Renders this:

NOTE THIS IS A DUMMY

Change the label

This is similar to the "Simple" Advanced Search - except you are able to define the search button text. This example changes the default "Search!" text with "Find me!".

[[include :csi:include:adv-search text=Find me!]]


Renders this:

NOTE THIS IS A DUMMY

Hiding filters

This is similar to the "Simple" Advanced Search - except you are able hide certain filter fields. This example hides the title filter field.

[[include :csi:include:adv-search showTitle=none]]


Renders this:

NOTE THIS IS A DUMMY

Setting default values

This is similar to the "Simple" Advanced Search - except the filter fields can have a default value. This example shows the default title value as being "community".

[[include :csi:include:adv-search defaultTitle=community]]


Renders this:

NOTE THIS IS A DUMMY

Enforcing default values

This is the most powerful option of all. It is able to define a default filter criteria and enforce it. In this example, you may set the default search filter to be only searching pages from the _default and doc categories. You are then able to enforce this be not allowing the user to change this option. Even if changed, the final search result will end up displaying the results with the default filter applied. Finally, the category filter is hidden to prevent users from wanting to change it.

[[include :csi:include:adv-search
|defaultCategory=_default,doc
|showCategory=none
|enforceDefault=true]]


Renders this:

NOTE THIS IS A DUMMY

Wasn't that easy!? Copy and paste :)
If you have any questions on how to set up this include, leave a comment here or at the CSI site.

~ Kenneth Tsang


Thanks to tsangk for this great snippet: conditional-blocks


text above inserted with:

[[include :snippets:if START |unique=1|type=equal|var1=%%name%%|var2=conditional-blocks]]
**##red|Thanks to tsangk for this great snippet:##** [[[code:conditional-blocks]]]
[[include :snippets:if END]]



Other snippets posted by Helmut_pdorf

Todo List with Data Forms - 30 Apr 2015 14:59
Html(embed) code opening in new window/tab - 29 Oct 2014 09:05
Facebook Button - 27 Dec 2013 15:03
Sorted-ListPages-List - 19 Aug 2013 15:56
Top Nav Menu with ListPages - 16 Feb 2012 01:48
Schedules - 16 Feb 2012 01:40
Use any html code on a page - 16 Feb 2012 01:34
Find untagged pages - 15 Feb 2012 00:52


Rate this solution

If you think this solution is useful — rate it up!

rating: +4+x
Add a New Comment
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License