Skip to main content

Add search box to navbar with Bootstrap Package

This works with Bootstrap Package 12 and Typo3 11.5

Firstly make sure you have a search plugin working. I used indexed search from the team at typo3.

  1. Add or check your search page and get pageID
  2. Add the following to your template -> setup for site wide search box replace 84 with your pageID
    # Searchbox
    lib.searchbox = COA_INT
    lib.searchbox {
        10 = TEXT
        10 {
            typolink {
                parameter = 84
                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="Search" />
            )
            20 = COA
            20 {            
                10 = TEXT
                10.value = <span class="input-group-btn"><button type="submit" class="btn btn-primary">GO</button></span>
            }
        }
        wrap = | </div></form>
    }
  3. in ext:bootstrap_package/Resources/Private/Partials/Dropin/Navigation/MainBefore.html add the following after the comment line.
      <section class="searchbox-wrapper">    <f:cObject typoscriptObjectPath="lib.searchbox" /> </section>
  4. Clear your cache
  5. Look at the FE of your website