首页 > 解决方案 > prefill search field of indexed search in TYPO3 v9

问题描述

I wonder how I can prefill the search field on the new indexed_search in TYPO3 v9. In older versions i put a searchfield in the head of my site:

<form method="post" action="https//linktomysearchpage" style="margin:0;">
<input type="text" placeholder="Suche" name="tx_indexedsearch[sword]"><span class="site-search-bg">
<button type="submit" name="tx_indexedsearch[submit_button]"><i class="icon-lupe"></i></button>

When jumping from this input field to the search page with the indexed_search plugin the search field of the plugin is filled and a result list is shown.

But in version 9 this does not work anymore. Something has changed. Any help? Thanks!

标签: typo3typo3-9.x

解决方案


You should not use plain html but rather the fluid templates (templates are now fluid based). Example for integrating a „header search box“ on all pages like this:

lib.searchBox = USER
lib.searchBox {
    userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
    vendorName = TYPO3\CMS
    extensionName = IndexedSearch
    pluginName = Pi2
    switchableControllerActions {
        Search {
            1 = form
            2 = search
        }
    }
    view =< plugin.tx_indexedsearch.view
    view {
        templateRootPaths {
            20 = EXT:sitepackage/Resources/Private/Extension/IndexedSearch/Header/Templates/
        }
        partialRootPaths {
            20 = EXT:sitepackage/Resources/Private/Extension/IndexedSearch/Header/Partials/
        }
        layoutRootPaths {
            20 = EXT:sitepackage/Resources/Private/Extension/IndexedSearch/Header/Layouts/
        }
    }
    settings =< plugin.tx_indexedsearch.settings
}

推荐阅读