TS-based Searchbox for Indexed Search

Submitting your vote...
Rating: 4.6 of 5. 12 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.htmlSpecialChars = 1
    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.




Comments


web, 01-11-07 10:59:
How do you place the search box on each page if you are using templavoila?
Goerni, 08-03-08 21:58:
Hello, the Link which is then generated is noch XHTML conform. Can somebody tell me how that works.

The generated HTML Code is like this:

…uche</span><form action="suche.html?&L=0" method="post" id="searchform" name=....

and the Ampersand is invalid.

Maybe someone have the same error.
Marijn, 26-08-08 00:57:
Fantastic! This made my life a whole lot easier, one little COA and my whole website with all of its templates uses the searchfunction. Thank you!
Charley, 07-07-09 01:01:
Same thing slightly changed for tableless design. There is a div class="clearer" to clear any floated elements in the search form if you apply float. If you don't float anything, then you could remove that "clearer" div on the last line:

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">
20 = COA
20 {
10 = TEXT
10.data = GPvar : tx_indexedsearch |sword
10.wrap = <input name="tx_indexedsearch[sword]" value="|" class="searchbox-sword" type="text" />
20 = COA
20 {
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 {
10 = TEXT
10.value = Advanced search »
10.typolink.parameter = {$plugin.tx_indexedsearch.searchUID}
10.typolink.additionalParams = &tx_indexedsearch[ext]=1
if.isTrue = {$plugin.tx_indexedsearch.showAdvanced}
}
wrap = |</form><div class="clearer">.</div></div>
}
Allan, 03-05-10 14:45:
Can't seem to get this one working - When I pess submit it just goes to the page with the search form on. But doesn't perform a search.

Any idea why?
Simon, 11-05-10 10:27:
I get the same result as Allan, 03-05-10 12:45:
Stig, 10-06-10 21:16:
lib.searchbox = COA_INT
lib.searchbox {
stdWrap.prefixComment = 2 | lib.searchbox
10 = TEXT
10.cObject = TEXT
10.cObject.typolink.parameter = {$plugin.tx_indexedsearch.searchUID}
10.cObject.typolink.returnLast = url
10.htmlSpecialChars = 1
10.wrap = <form action="|" method="post" id="indexedsearch">
20 = COA
20 {
wrap = |
15 = TEXT
15 {
data = GPvar : tx_indexedsearch|sword
wrap =<input type="hidden" value="0" name="tx_indexedsearch[type]"/><input name="tx_indexedsearch[sword]" value="|" type="text" />
}
20 = COA
20 {
wrap = |
10 = TEXT
10.value = <input type="hidden" name="tx_indexedsearch[sections]" value="0" />
20 = TEXT
20.value = <input type="submit" name="tx_indexedsearch[submit_button]" value="Search" />
20.stdWrap.insertData = 1
}
}
wrap = | </form>
}
Brian Hauge, 23-06-10 13:09:
I also don't get any search results on the page where I have set my

plugin.tx_indexedsearch.searchUID

Add comment

* - required field

*



*
*

Top 10 Updates

Nice fonts using Google font API geändert am  20-May-2010 16:36:47
TS-based Searchbox for Indexed Search  geändert am  18-May-2010 18:27:15
TYPO3 SEO geändert am  30-Apr-2010 09:44:22
Search engine friendly graphical headers in TYPO3 geändert am  30-Apr-2010 09:33:44
Creating a simple Infocenter using TYPO3 geändert am  17-Nov-2009 12:12:52
Making the Section Menu work correctly with TemplaVoila geändert am  05-May-2009 12:27:17
Show pages with type "Not in Menu" in a sitemap geändert am  05-May-2009 12:11:17
Implementation of the DHTML menu from brainjar.com  geändert am  01-Feb-2009 14:02:48
Sample DHTML menu geändert am  01-Feb-2009 13:51:25
A introduction to the CONTENT object geändert am  26-Jan-2009 13:20:39

Latest comments

20-Aug-2010 16:31:13
pritam schrieb: Hello, Can any body tell me how to add the realurl in the typo3.
Articles
17-Aug-2010 15:25:30
Graham Solomon schrieb: I have developed a nice extension for using this Google Font API with TYPO3, along with their web...
Nice Fonts using Google font API
12-Aug-2010 17:39:44
Ritesh Jaiswal schrieb: I have added the above code into page template but it is not working. It only index the page into...
Index search
Deutsch
Search: