Search code examples
formssearchtypo3realurl

TYPO3 Indexed Search Url on submit


i use TYPO3 7.6.10 i use indexed_search 7.6.0 when i submit form i go to the target page and i get the results. The url of target page is:

search.html?tx_indexedsearch_pi2%5Baction%5D=search&tx_indexedsearch_pi2%5Bcontroller%5D=Search

i want to remove action and controller variable form url to get:

search.html

i can do that adding a configuration to real url like this:

'searchConfiguration' => array(
                        array(
                                'GETvar' => 'tx_indexedsearch_pi2[action]',
                                'valueMap' => array(),
                                'noMatch' => 'bypass'
                        ),
                        array(
                                'GETvar' => 'tx_indexedsearch_pi2[controller]',
                                'valueMap' => array(),
                                'noMatch' => 'bypass'
                        )),'135' => 'searchConfiguration'

Now i get a nice url but the submitted data is not sent! How can i resolve it?


Solution

  • Those parameters are required for the controller to be routed by the request. Without them the sWord will not become processed by the controller and you will not get any results.

    Instead of bypassing them you can rewrite them to get something like /search/perform/results/ or you can configure your form to use method="POST" instead of "GET" and add those parameters above into hidden fields of the form and make sure the form attribute does not have the arguments as parameters in the action. Example form in the result:

    <form method="POST" class="header-search-form hidden-xs hidden-sm" action="suche.html">
    
                                <input type="hidden" name="tx_indexedsearch_pi2[controller]" value="Search">
                                <input type="hidden" name="tx_indexedsearch_pi2[action]" value="search">
    
                                <div class="input-group">
                                    <input type="text" class="search-query form-control" placeholder="Suchen" id="default-search-input" name="tx_indexedsearch_pi2[search][sword]">
                                    <span class="input-group-btn">
                                        <button class="btn" type="button">
                                            <i class="fa fa-search" aria-hidden="true"></i>
                                        </button>
                                    </span>
                                </div>
                            </form>