TS-based Searchbox for Indexed Search

Submitting your vote...
Rating: 4.4 of 5. 5 vote(s).
Click the rating bar to rate this item.

Suppose you want to insert a searchbox on all pages, but don't want to install additional extensions like "macina_searchbox", you can do it all by TS. :)

 

First create a page, and insert the indexed search plugin on that page, and make sure the search are working..

Then insert the code below in your TS setup, and change the value of the constant "plugin.tx_indexedsearch.searchUID" to be the pageID of the page you just created.

 

Setting the "plugin.tx_indexedsearch.showAdvanced=1" will also display a link below the searchbox, which points to the Advanced searchform.

 

Place this in CONSTANTS:

 

plugin.tx_indexedsearch.searchUID = 82
plugin.tx_indexedsearch.showAdvanced = 0

 

 

Place this in SETUP:

 

# --- SEARCHBOX OBJECT ----------------------------------
lib.searchbox = COA_INT
lib.searchbox {
  stdWrap.prefixComment = 2 | lib.searchbox
  10 = TEXT
  10.typolink.parameter = {$plugin.tx_indexedsearch.searchUID}
  10.typolink.returnLast = url
  10.wrap = <div id="indexedsearchbox"><form action="|" method="post" id="indexedsearch"><table cellpadding="0" cellspacing="0" border="0">
  20 = COA
  20 {
    wrap = <tr> | </tr>
    10 = TEXT
    10.data = GPvar : tx_indexedsearch |sword
    10.wrap = <td><input name="tx_indexedsearch[sword]" value="|" class="searchbox-sword" type="text" /></td>
    20 = COA
    20 {
      wrap = <td align="right">&nbsp;|</td>
      10 = TEXT
      10.value = <input type="hidden" name="tx_indexedsearch[sections]" value="0" />
      20 = TEXT
      20.value = <input name="tx_indexedsearch[submit_button]" value="Search" type="hidden" />
      30 = TEXT
      30.value = <input name="search" src="fileadmin/templates/images/search.gif" value="Search" class="searchbox-button" type="image" />
    }
  }
  30 = COA
  30 {
    wrap = <tr>|</tr>
    10 = TEXT
    10.value = Advanced search »
    10.typolink.parameter = {$plugin.tx_indexedsearch.searchUID}
    10.typolink.additionalParams = &tx_indexedsearch[ext]=1
    10.wrap = <td align="right" colspan="2">|</td>
    if.isTrue = {$plugin.tx_indexedsearch.showAdvanced}
  }
  wrap = | </table></form></div>
}

 

 

This snippet was submited by Peter Klein.


Top 10 Updates

Using Transparent PNG's in IE5/6 without JavaScript geändert am  04-Oct-2008 12:27:15
Using lightbox without extension geändert am  13-Jun-2008 14:20:51
Custom field for GMENU alt text geändert am  13-Jun-2008 13:58:07
Extending typoscript properties with stdWrap geändert am  13-Jun-2008 13:54:32
Create menus using data from other tables than "pages" V2  geändert am  24-Mar-2008 13:02:09
Login geändert am  17-Mar-2008 12:47:52
Forum geändert am  17-Mar-2008 10:07:47
Who is Typo3wizard.com geändert am  26-Dec-2007 16:07:32
Menu as un-nested lists (iphone navigation) geändert am  29-Oct-2007 15:05:53
IF Conditions with AND and OR operators geändert am  16-Oct-2007 19:16:04
Deutsch
Search: