Search code examples
typo3-8.xtx-indexed-search

Create custom search form indexed_search TYPO3 v8


I'm trying to add a custom search form into my template, the TypoScript I used in a v7 install no longer works.

If I copy the Fluid form used in the extension (Form.html) and place it into one of my Fluid template a search box appears but it posts back to itself, even though I have set a rootPidList in my constants. This is the code I copy:

<f:form action="search" method="post" id="tx_indexedsearch" pageUid="{settings.targetPid}">
<div class="tx-indexedsearch-hidden-fields">
    <f:form.hidden name="search[_sections]" value="0" />
    <f:form.hidden name="search[_freeIndexUid]" id="tx_indexedsearch_freeIndexUid" value="_" />
    <f:form.hidden name="search[pointer]" id="tx_indexedsearch_pointer" value="0" />
    <f:form.hidden name="search[ext]" value="{searchParams.ext}" />
    <f:form.hidden name="search[searchType]" value="{searchParams.searchType}" />
    <f:form.hidden name="search[defaultOperand]" value="{searchParams.defaultOperand}" />
    <f:form.hidden name="search[mediaType]" value="{searchParams.mediaType}" />
    <f:form.hidden name="search[sortOrder]" value="{searchParams.sortOrder}" />
    <f:form.hidden name="search[group]" value="{searchParams.group}" />
    <f:form.hidden name="search[languageUid]" value="{searchParams.languageUid}" />
    <f:form.hidden name="search[desc]" value="{searchParams.desc}" />
    <f:form.hidden name="search[numberOfResults]" value="{searchParams.numberOfResults}" />
    <f:form.hidden name="search[extendedSearch]" value="{searchParams.extendedSearch}" />
</div>
<fieldset>
    <legend><f:translate key="form.legend" /></legend>
    <div class="tx-indexedsearch-form">
        <label for="tx-indexedsearch-searchbox-sword"><f:translate key="form.searchFor" />:</label>
        <f:form.textfield name="search[sword]" value="{sword}" id="tx-indexedsearch-searchbox-sword" class="tx-indexedsearch-searchbox-sword" />
    </div>
    <div class="tx-indexedsearch-search-submit">
        <f:form.submit name="search[submitButton]" value="{f:translate(key: 'form.submit')}" id="tx-indexedsearch-searchbox-button-submit" class="tx-indexedsearch-searchbox-button" />
    </div>
</fieldset>

And my typoscript:

config.index_enable = 1
page.config.index_enable = 1
plugin.tx_indexedsearch.settings.targetPid = 31

If I add the stock indexed search plugin to a random page, this will work. Just to rule it out, I've also disable realurl just in case.

Thanks again T3 community.


Solution

  • if you just copy the search template into your output/ page template, there is no plugin available which provides values for the specific variables needed in this template-part.

    • either you use an output of a page where you have inserted the plugin (copy from HTML-source)
    • or you insert the plugin in all pages:
      • this can be done with a column you inherit and where the plugin is inserted on top level
      • or you use typoscript to render the plugin into a fluid-variable and display the generated HTML in your (page-)template.