Jan 21, 2009

MnoGoSearch with advanced search form

As I wrote earlier, I spend a lot of time doing development for TYPO3 extensions. In particular I spent a lot of time on the new feature of the mnogosearch TYPO3 extension (version 2.2). The feature is an advanced search form. At the moment this form allows to select parts of the site where search should be performed. Here is how it looks like:

Enabling the advanced search form

To enable the advanced search form in the mnogosearch TYPO3 extension, the following two steps should be taken:
  • TypoScript of the web site should be modified
  • More than one indexing configuration should exist

To preserve compatibility with previous versions of the extension, the advanced search form is disabled in this version of the site by TypoScript. It has to be enabled manually using the following TypoScript:

plugin.tx_mnogosearch_pi1.form.advanced.siteSelector = radio

Other possible values for this setting are:
  • disabled
  • select
  • checkboxes
Notice that the advanced search form will be enabled by default in the next version of the extension (2.2.1).

Another necessary step is to define more than one indexing configuration. The form is built around the indexing configurations. For example, the image above uses four configurations:

  • example.com ("server", "allow")
  • Table: FAQ
  • Table: News
  • Table: Forums

Notice that each of these configurations will allow searching only inside a certain area of the site. For example, the first configuration allows searching normal pages but it will not search FAQ or News or Forums. So obviously there is a need for "Everywhere" option. It is enabled by default by the following TypoScript:

plugin.tx_mnogosearch_pi1.form.advanced.siteSelector.searchAll = 1

Enhancing the form

We may want to set one of the configurations as a default. A user will see it checked (or selected in the select box) when it navigates to the advanced search page:

plugin.tx_mnogosearch_pi1.form.advanced.siteSelector.default = 5

"5" there is the id of the default indexing configuration.

And finally you may want to hide some configurations from the form only. For example, you may want to have to sections in the form:

  • whole site
  • everywhere except news

In this case you add two indexing configurations to the flexform plugin ("http://example.com/" and "Table: News". Then you exclude news from the form:

plugin.tx_mnogosearch_pi1.form.advanced.siteSelector.exclude = 6

We also set title of "http://example.com/" indexing configuration to "Everywhere except news". Now we will have two entries in the form:

  • "Everywhere" (created automatically by the plugin)
  • "Everywhere except news" (created by the "http://example.com/" indexing configuration)

So the configuration of the form is very flexible. There is also a hook (not in the documentation yet) that allows to provide additional items to the advanced search form to search non–TYPO3 applications.

This form is already in use on one of our sites in Latvia (in fact it was made for this site). I hope other users of the extensions will find it useful too.

No comments:

Post a Comment