Skip to content

TYPO3 extension that adds autocomplete functionality to indexed search fields.

License

Notifications You must be signed in to change notification settings

RKlingler/autocomplete_for_indexedsearch

Repository files navigation

TYPO3 12 TYPO3 13 TYPO3 13

TYPO3 Extension: Autocomplete for IndexedSearch

This extension adds autocomplete functionality to TYPO3 indexed search fields.

TYPO3 Indexed Search autocomplete suggestions

Features

  • Supports TYPO3 12 and 13
  • No further dependencies
  • Comes with limited styling for easy customizability

Installation

The recommended way to install Autocomplete for IndexedSearch is by using Composer:

composer require rkl/autocomplete-for-indexedsearch

Setup

1. Include the static TypoScript of the extension

  1. Go to Site Management -> TypoScript
  2. Open your TypoScript template and click "Edit the whole TypoScript record"
  3. In the tab "Advanced Options", include the TypoScript set: "Autocomplete for Indexed Search (autocomplete_for_indexedsearch)"

2. Override the Form.html template from indexed_search

  1. Copy the partial from EXT:indexed_search/Resources/Private/Partials/Form.html to your own site package, for example to EXT:my_sitepackage/Resources/Private/IndexedSearch/Partials/Form.html
  2. Add your partial root path to the plugin configuration of Indexed Search in the TypoScript of your site package:
plugin {
  tx_indexedsearch {
    view {
      partialRootPaths.200 = EXT:site_package/Resources/Private/IndexedSearch/Partials/
    }
  }
}

3. Place the ViewHelper to render suggestions

Add the ViewHelper <rkl:autocompleteSuggestions /> to your overridden Form.html. It renders the container in which suggestions will be displayed.

<html
  xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
  xmlns:rkl="http://typo3.org/ns/RKL/AutocompleteForIndexedSearch/ViewHelpers"
  data-namespace-typo3-fluid="true"
>
<!-- ... -->
<rkl:autocompleteSuggestions searchonclick="0" minlength="2" />

Add the ViewHelper wherever it suits your styling needs the best. Ideally it's placed close to the search field. Also remember to add the namespace RKL/AutocompleteForIndexedSearch/ViewHelpers like shown in the example.

ViewHelper attributes

The autocompleteSuggestions ViewHelper provides the following attributes to manipulate the behavior of the autocomplete suggestions:

Attribute Allowed values Description
searchonclick bool (0/1) defines whether to instantly submit the search form when a suggestion is clicked
minlength int minimum string length of the search term for autocompletion to start

Optional: Add a Route Enhancer

For prettier autocomplete URLs you can add the autocomplete page type to your routeEnhancers:

routeEnhancers:
  PageTypeSuffix:
    type: PageType
    index: ''
    map:
      search-autocomplete: 7603976

Links

URL
Repository: https://github.com/RKlingler/autocomplete_for_indexedsearch/
TER: https://extensions.typo3.org/extension/autocomplete_for_indexedsearch
Packagist: https://packagist.org/packages/rkl/autocomplete-for-indexedsearch

Sponsorships

PayPal: www.paypal.me/rukling

About

TYPO3 extension that adds autocomplete functionality to indexed search fields.

Resources

License

Stars

Watchers

Forks

Packages

No packages published