TS-based Searchbox for Indexed Search

Submitting your vote...
Rating: 4.6 of 5. 16 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 09:59:
How do you place the search box on each page if you are using templavoila?
Goerni, 08-03-08 20: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, 25-08-08 22: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, 06-07-09 23: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 12: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 08:27:
I get the same result as Allan, 03-05-10 12:45:
Stig, 10-06-10 19: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 11:09:
I also don't get any search results on the page where I have set my

plugin.tx_indexedsearch.searchUID
Thomas, 21-09-10 08:27:
It is missing a field for the stype and one for the locationData.
Setup below is working for me!


# --- SEARCHBOX OBJECT ----------------------------------
lib.searchBox = COA_INT
lib.searchBox {
stdWrap.prefixComment = 2 | lib.searchBox
10 = TEXT
10.typolink.parameter = {$plugin.tx_indexedsearch.searchUID}
10.typolink.no_cache = 1
10.typolink.returnLast = url
10.wrap = <form action="|" method="post" id="indexedsearch" name="mysearch" enctype="multipart/form-data" onsubmit="return validateForm('mysearch','','','','')"><fieldset>
20 = COA
20 {
wrap = |
40 = TEXT
40.htmlSpecialChars = 1
40.data = GPvar : tx_indexedsearch |sword
40.wrap = <input name="sword" value="|" id="sword" class="searchbox-sword" type="text" />
20 = COA
20 {
wrap = |
5 = TEXT
5.value = <input type="hidden" name="stype" value="L0" />
10 = TEXT
10.value = <input type="hidden" name="tx_indexedsearch[sections]" value="0" />
20 = TEXT
20.value = <input name="scols" value="pages.title-subtitle-keywords-description:tt_content.header" type="hidden" />
30 = TEXT
30.value = <input name="submit" value="Suche" class="searchbox-button" type="submit" />
}
}
30 = COA
30 {
wrap = |
10 = TEXT
10.value = Advanced search »
10.typolink.parameter = {$plugin.tx_indexedsearch.searchUID}
10.typolink.additionalParams = &tx_indexedsearch[ext]=1
10.wrap = <p> | </p>
if.isTrue = {$plugin.tx_indexedsearch.showAdvanced}

}
wrap = |</fieldset></form>
}
#----------------- SEARCHBOX END ----------------------------

Add comment

* - required field

*



*
*

Top 10 Updates

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

Latest comments

17-May-2013 10:09:34
Nicolas schrieb: If an extension or orther return a content empty, this solution not working. I not have the...
Wrap only if not empty
22-Apr-2013 12:08:26
morkel schrieb: hi i am new on typ03 and want to open a form on lightbox. when we click on image their a form will...
Using lightbox without extension
04-Mar-2013 13:33:47
Sebastian schrieb: Vergesse das immer wieder. Vielen Dank an dich und an Google :)
Wrap only if not empty
Deutsch
Search: