tsangktsangk 04 Dec 2011 10:02

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


Recommend this post?

rating: +4+x


What do you think? Give us your thoughts!

Add a New Comment