Search code examples
typoscriptfaceted-searchsearch-boxtypo3-9.x

Searchbox in menu for TYPO3 9.5 LTS


I'm currently developing a Website with the new TYPO3 9.5 LTS Version and need to implement a search-box.
This search-box should appear on all pages in the menu without any advanced search link or other unnecessary things. Just a simple input field to search for content on the website.

In the past I did this with the Faceted Search extension (ke_search). But this extension currently only supports TYPO3 up to Version 8.7.99.

Does anyone already know a possibility to provide the same functionality in TYPO3 9.5 LTS?


Solution

  • For the moment we created a searchbox with the indexed_search until ke_search is ready for this Typo3 Version.

    Our TYPOScript for the searchbox with bootstrap input-group:

    # Searchbox
    lib.searchbox = COA_INT
    lib.searchbox {
        10 = TEXT
        10 {
            typolink {
                parameter = 110
                additionalParams = &tx_indexedsearch_pi2[action]=search&tx_indexedsearch_pi2[controller]=Search
                useCacheHash = 1
                returnLast = url
            }
            wrap = <form action="|" method="post" id="search-block-form" class="form-search"><input type="hidden" name="tx_indexedsearch_pi2[search][languageUid]" value="0" /><div class="input-group">
        }    
        20 = COA
        20 {
            10 = TEXT
            10.data = GPvar : tx_indexedsearch |sword
            10.wrap ( 
                <input class="form-control" type="text" name="tx_indexedsearch_pi2[search][sword]" id="tx-indexedsearch-searchbox-sword" placeholder="Suche" />
            )
            20 = COA
            20 {            
                10 = TEXT
                10.value = <span class="input-group-btn"><button type="submit" class="btn btn-default btn-primary"><span class="icon glyphicon glyphicon-search" aria-hidden="true"></span></button></span>
            }
        }
        wrap = | </div></form>
    }
    

    And with this TYPOScript we can add it in the fluid template like this:

    <section class="searchbox-wrapper">
        <f:cObject typoscriptObjectPath="lib.searchbox" />
    </section>