Maintainers
Pricing
Enterprise
More
More
Documentation
Try Live
Rankings
Install
Blog
Docs7
Ask
New
Add Docs
Ke Search
https://github.com/tpwd/ke_search
Admin
A project focused on providing search functionality.
Tokens:
17,585
Snippets:
259
Trust Score:
6.7
License:
GPL-3.0
Update:
4 months ago
Context
Chat
Benchmark
73
Latest
Show doc for...
Code
Info
Show Results
Tokens:
Raw
Copy
Link
Tokens:
Raw
Copy
Link
### Install dependencies and setup Source: https://github.com/tpwd/ke_search/blob/master/README.rst Install project dependencies and configure coding standards files. ```bash cd ke_search composer install composer exec typo3-coding-standards setup ``` -------------------------------- ### Install ke_search via Composer Source: https://github.com/tpwd/ke_search/blob/master/Documentation/QuickStart/Index.rst Use this command to install the extension in a TYPO3 project. ```bash composer require tpwd/ke_search ``` -------------------------------- ### Start the indexer via CLI Source: https://github.com/tpwd/ke_search/blob/master/Documentation/CommandLine/Index.rst Executes the indexer for all configurations. Can be scheduled in the TYPO3 scheduler. ```bash vendor/bin/typo3 ke_search:indexing ``` -------------------------------- ### Start indexing process via CLI Source: https://github.com/tpwd/ke_search/blob/master/Documentation/Indexing/Index.rst Commands to trigger the indexing process manually from the command line. ```bash vendor/bin/typo3 ke_search:indexing ``` ```bash vendor/bin/typo3 ke_search:indexing --indexingMode=incremental ``` -------------------------------- ### Override Startingpoint via TypoScript Source: https://github.com/tpwd/ke_search/blob/master/Documentation/Configuration/OverrideRecordStoragePage.rst Configure the starting point and recursive search behavior for ke_search plugins using TypoScript settings. ```typoscript plugin.tx_kesearch_pi1.overrideStartingPoint = 123 plugin.tx_kesearch_pi1.overrideStartingPointRecursive = 1 plugin.tx_kesearch_pi2.overrideStartingPoint = 123 plugin.tx_kesearch_pi2.overrideStartingPointRecursive = 1 ``` -------------------------------- ### Configure Multiple Mask Tables Source: https://github.com/tpwd/ke_search/blob/master/Documentation/Indexing/IndexerTypes/Pages.rst Example of indexing multiple additional tables for a single CType. ```ini [mask_mytest] table = tx_mask_repeating1 referenceFieldName = parentid fields[] = tx_mask_name [mask_mytest.1] table = tx_mask_repeating2 referenceFieldName = parentid fields[] = tx_mask_title ``` -------------------------------- ### View log file output Source: https://github.com/tpwd/ke_search/blob/master/Documentation/Logging/Index.rst Example of the log file content generated during the indexing process, showing timestamps, log levels, and component information. ```none Thu, 20 Dec 2018 14:12:20 +0100 [NOTICE] request="d40b2d51fe977" component="Tpwd.KeSearch.Indexer.IndexerRunner": ============================ = Indexing process started = ============================ Thu, 20 Dec 2018 14:12:21 +0100 [ERROR] request="d40b2d51fe977" component="Tpwd.KeSearch.Indexer.IndexerRunner": The path to catdoctools is not correctly set in the extension configuration. You can get the path with "which catdoc". Thu, 20 Dec 2018 14:12:21 +0100 [ERROR] request="d40b2d51fe977" component="Tpwd.KeSearch.Indexer.IndexerRunner": The path for xls2csv is not correctly set in extConf. You can get the path with "which xls2csv". Thu, 20 Dec 2018 14:12:21 +0100 [ERROR] request="d40b2d51fe977" component="Tpwd.KeSearch.Indexer.IndexerRunner": The path to catppttools is not correctly set in extension configuration. You can get the path with "which catppt". Thu, 20 Dec 2018 14:12:21 +0100 [WARNING] request="d40b2d51fe977" component="Tpwd.KeSearch.Indexer.IndexerRunner": Could not index file /var/www/html/web/fileadmin/test/test-invalid.xlsx. Thu, 20 Dec 2018 14:12:21 +0100 [WARNING] request="d40b2d51fe977" component="Tpwd.KeSearch.Indexer.IndexerRunner": Could not index file /var/www/html/web/fileadmin/test/test-invalid.docx. Thu, 20 Dec 2018 14:12:21 +0100 [WARNING] request="d40b2d51fe977" component="Tpwd.KeSearch.Indexer.IndexerRunner": Could not index file /var/www/html/web/fileadmin/test/test-invalid.pptx. Thu, 20 Dec 2018 14:12:21 +0100 [WARNING] request="d40b2d51fe977" component="Tpwd.KeSearch.Indexer.IndexerRunner": Could not index file /var/www/html/web/fileadmin/test/pdf-example-password.original.pdf. ``` -------------------------------- ### ke_search:indexing Source: https://github.com/tpwd/ke_search/blob/master/Documentation/CommandLine/Index.rst Starts the indexer to process all indexer configurations. Can be used in the TYPO3 scheduler for automated indexing. ```APIDOC ## ke_search:indexing ### Description Starts the indexer to process all indexer configurations. ### Parameters #### Options - **-m, --indexingMode** (string) - Optional - Indexing mode, either "full" (default) or "incremental". Default is "full". ``` -------------------------------- ### Configure simple speaking URL route enhancer Source: https://github.com/tpwd/ke_search/blob/master/Documentation/Configuration/RoutingSpeakingUrls.rst A basic configuration example mapping one filter and the search word to a speaking URL structure. ```yaml routeEnhancers: KeSearch: type: Plugin routePath: '{filter_13}/{sortByField}/{sortByDir}/{resetFilters}/{page}/{sword}' namespace: 'tx_kesearch_pi1' defaults: sortByField: 'score' sortByDir: 'desc' resetFilters: '0' page: '1' sword: '' filter_13: '-' requirements: sortByField: '(score|title|customranking|sortdate)?' sortByDir: '(asc|desc)?' resetFilters: '[0-9]?' page: '\d+' filter_13: '[0-9a-zA-Z-]*' aspects: sortByField: type: StaticValueMapper map: score: 'score' customranking: 'customranking' title: 'title' sortByDir: type: StaticValueMapper map: asc: 'asc' desc: 'desc' resetFilters: type: StaticRangeMapper start: '0' end: '1' page: type: StaticRangeMapper start: '1' end: '99' filter_13: type: KeSearchTagToSlugMapper sword: type: KeSearchUrlEncodeMapper ``` -------------------------------- ### Configure Mask Sub-elements with Parent Table Source: https://github.com/tpwd/ke_search/blob/master/Documentation/Indexing/IndexerTypes/Pages.rst Example of indexing sub-elements where a parentTable relationship is required. ```ini [mask_mytest] table = tx_mask_repeating1 referenceFieldName = parentid fields[] = tx_mask_name [mask_mytest.1] table = tx_mask_repeating2 parentTable = tx_mask_repeating1 referenceFieldName = parentid fields[] = tx_mask_title ``` -------------------------------- ### Execute a custom search with SearchService Source: https://github.com/tpwd/ke_search/blob/master/Documentation/PublicSearchApi/Index.rst Inject the SearchService and use SearchRequest::fromArray to define search parameters like search terms, starting points, and filters. ```php use Tpwd\KeSearch\Domain\Search\SearchRequest; use Tpwd\KeSearch\Service\SearchService; class MyController { public function __construct( private readonly SearchService $searchService ) {} public function myAction(): void { $request = SearchRequest::fromArray([ 'searchWord' => 'my search term', 'startingPoints' => '1,2,3', // comma-separated page UIDs 'limit' => 20, 'filter' => [123 => ['tag1', 'tag2']], // optional: filter UID => selected option tags ]); $result = $this->searchService->search($request); $rows = $result->getResults(); // array of tx_kesearch_index rows $total = $result->getTotalCount(); } } ``` -------------------------------- ### Complex search query Source: https://github.com/tpwd/ke_search/blob/master/Documentation/Behaviour/Options.rst Example of combining multiple conjunctions in a single search string. ```none “+Auto +cheap -expensive“ ``` -------------------------------- ### Enable filters in TypoScript Source: https://github.com/tpwd/ke_search/blob/master/Documentation/Templating/FiltersInResultList.rst Set this configuration in your TypoScript setup to enable filter rendering in the result list plugin. ```typoscript plugin.tx_kesearch_pi2.includeFilters = 1 ``` -------------------------------- ### Generate documentation Source: https://github.com/tpwd/ke_search/blob/master/README.rst Render the documentation locally into an HTML format. ```bash composer docs:generate ``` -------------------------------- ### Run unit tests Source: https://github.com/tpwd/ke_search/blob/master/README.rst Execute the unit test suite. ```bash composer test:unit ``` -------------------------------- ### Clone the repository Source: https://github.com/tpwd/ke_search/blob/master/README.rst Use this command to clone the ke_search project locally. ```bash git clone git@github.com:tpwd/ke_search.git ``` -------------------------------- ### Generate search links with filters Source: https://github.com/tpwd/ke_search/blob/master/Documentation/Templating/LinkViewHelper.rst Demonstrates how to use the kesearch:link view helper to create links with search words and various filter configurations. ```html <html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" xmlns:kesearch="http://typo3.org/ns/Tpwd/KeSearch/ViewHelpers" data-namespace-typo3-fluid="true"> <ul> <li><kesearch:link page="85" piVars="{sword: 'elephants'}" class="my-link-class">Search for elephants</kesearch:link></li> <li><kesearch:link page="85" piVars="{filter_13: 'page'}" class="my-link-class">Show all pages</kesearch:link></li> <li><kesearch:link page="85" piVars="{sword: 'elephants', filter_13: 'page'}" class="my-link-class">Search for elephants in pages</kesearch:link></li> <li><kesearch:link page="85" piVars="{sword: 'elephants', filter_13: 'page', filter_3_278: 'syscat92'}" class="my-link-class">Search for elephants in pages and use a checkbox filter</kesearch:link></li> </ul> </html> ``` -------------------------------- ### Run PHP-CS-Fixer check Source: https://github.com/tpwd/ke_search/blob/master/README.rst Check code style compliance and generate a report log. ```bash composer test:php-cs-fixer ``` -------------------------------- ### Run a search based on current plugin context Source: https://github.com/tpwd/ke_search/blob/master/Documentation/PublicSearchApi/Index.rst Use SearchRequest::fromContext to inherit existing plugin configuration and filters, then optionally clear the search phrase. ```php use Tpwd\KeSearch\Domain\Search\SearchRequest; use Tpwd\KeSearch\Service\SearchService; // Inside a hook (e.g. modifyResultList) with access to the plugin $pObj: $customRequest = SearchRequest::fromContext($pObj)->withEmptySearchPhrase(); $customResult = $this->searchService->search($customRequest); $indexRows = $customResult->getResults(); // Use the rows for further processing $total = $customResult->getTotalCount(); ``` -------------------------------- ### Implement the hook class Source: https://github.com/tpwd/ke_search/blob/master/Documentation/Indexing/IndexerTypes/CustomContentFields.rst Define the class to handle field fetching and content modification for the indexer. ```php class AdditionalContentFields { public function modifyPageContentFields(&$fields, $pageIndexer) { // Add the field "subheader" from the tt_content table, which is normally // not indexed, to the list of fields. $fields .= ",subheader"; } public function modifyContentFromContentElement(string &$bodytext, array $ttContentRow, $pageIndexer) { // Add the content of the field "subheader" to $bodytext, which is, what // will be saved to the index. $bodytext .= strip_tags($ttContentRow['subheader']); } } ``` -------------------------------- ### Configure Bootstrap Package Accordion Indexing Source: https://github.com/tpwd/ke_search/blob/master/Documentation/Indexing/IndexerTypes/Pages.rst Add this configuration to the 'Additional tables for content elements' setting to index accordion items. ```ini [accordion] table = tx_bootstrappackage_accordion_item referenceFieldName = tt_content fields[] = header fields[] = bodytext ``` -------------------------------- ### Implement the custom filter renderer class Source: https://github.com/tpwd/ke_search/blob/master/Documentation/Filters/CustomFilter.rst Create a class with a customFilterRenderer method to handle the rendering logic. Ensure the rendertype is set to 'custom' and rawHtmlContent is populated to override default output. ```php <?php namespace Tpwd\KeSearchHooks; use Tpwd\KeSearch\Lib\Pluginbase; use TYPO3\CMS\Core\Utility\GeneralUtility; class ExampleFilterRenderer { public function customFilterRenderer(int $filterUid, array $options, Pluginbase $plugin, array &$filterData) { if ($filterData['rendertype'] == 'select') { /** @var \TYPO3\CMS\Fluid\View\StandaloneView $view */ $view = GeneralUtility::makeInstance(\TYPO3\CMS\Fluid\View\StandaloneView::class); $view->setTemplateRootPaths([10 => 'EXT:ke_search_hooks/Resources/Private/Templates']); $view->setTemplate('Filters/CustomFilter'); $view->assign('filter', $filterData); $filterData['rendertype'] = 'custom'; $filterData['rawHtmlContent'] = $view->render(); } } } ``` -------------------------------- ### Register FAL image attachments for custom indexers Source: https://github.com/tpwd/ke_search/blob/master/Documentation/Templating/Images.rst Configure the file reference mapping in ext_localconf.php to allow ke_search to index images attached to custom records. ```php $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['fileReferenceTypes'][INDEXER_KEY]['table'] = TABLE_NAME; $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['fileReferenceTypes'][INDEXER_KEY]['field'] = IMAGE_FIELD_NAME; ``` ```php $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['fileReferenceTypes']['fe_users']['table'] = 'fe_users'; $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['fileReferenceTypes']['fe_users']['field'] = 'image'; ``` -------------------------------- ### Locate Default Templates Source: https://github.com/tpwd/ke_search/blob/master/Documentation/Templating/CustomTemplates.rst The directory path where default templates are stored within the ke_search extension. ```none typo3conf/ext/ke_search/Resources/Private ``` -------------------------------- ### Run PHPStan analysis Source: https://github.com/tpwd/ke_search/blob/master/README.rst Perform static analysis with PHPStan and generate a report log. ```bash composer test:phpstan ``` -------------------------------- ### Run functional tests Source: https://github.com/tpwd/ke_search/blob/master/README.rst Execute the functional test suite. ```bash composer test:functional ``` -------------------------------- ### Configure Template Paths via TypoScript Source: https://github.com/tpwd/ke_search/blob/master/Documentation/Templating/CustomTemplates.rst Set the root paths for templates, partials, and layouts in your TypoScript constants to point to your site package. ```typoscript plugin.tx_kesearch.templateRootPath = EXT:mysite/Resources/Private/Templates/ke_search/ plugin.tx_kesearch.partialRootPath = EXT:mysite/Resources/Private/Partials/ke_search/ plugin.tx_kesearch.layoutRootPath = EXT:mysite/Resources/Private/Layouts/ke_search/ ``` -------------------------------- ### Configure MySQL full-text search word length Source: https://github.com/tpwd/ke_search/blob/master/Documentation/Configuration/SearchWordLength.rst Set the minimum word length for full-text indexing in the MySQL configuration file. ```text [mysqld] ft_min_word_len = 3 ``` -------------------------------- ### Render pagination navigation links Source: https://github.com/tpwd/ke_search/blob/master/Resources/Private/Partials/PageBrowser.html Renders the navigation structure for moving between result pages. ```html * «* < * {page}* {page}* > * » ``` -------------------------------- ### Configure Mask Element Indexing Source: https://github.com/tpwd/ke_search/blob/master/Documentation/Indexing/IndexerTypes/Pages.rst Basic configuration for indexing a Mask content element. ```ini [mask_list] table = tx_mask_content referenceFieldName = parentid fields[] = tx_mask_content_item ``` -------------------------------- ### Show indexer status Source: https://github.com/tpwd/ke_search/blob/master/Documentation/CommandLine/Index.rst Displays the current state of the indexer and progress if running. ```bash vendor/bin/typo3 ke_search:indexerstatus ``` -------------------------------- ### Partial word search syntax Source: https://github.com/tpwd/ke_search/blob/master/Documentation/Behaviour/Options.rst Use the asterisk wildcard to perform partial word searches. ```none "french cooking" pepp* ``` ```none "french cooking" pepper ``` ```none "french cooking" peppermint ``` -------------------------------- ### SearchRequest Factory Methods Source: https://github.com/tpwd/ke_search/blob/master/Documentation/PublicSearchApi/Index.rst Methods to instantiate a SearchRequest object from an array or existing plugin context. ```APIDOC ## SearchRequest::fromArray ### Description Creates a SearchRequest instance from an associative array of parameters. ### Signature `public static function fromArray(array $data): self` ## SearchRequest::fromContext ### Description Creates a SearchRequest instance based on the current plugin context, copying configuration, filters, and sorting. ### Signature `public static function fromContext(SearchContextInterface $context): self` ``` -------------------------------- ### Retrieve all matching UIDs efficiently Source: https://github.com/tpwd/ke_search/blob/master/Documentation/PublicSearchApi/Index.rst Use searchUids to bypass pagination and retrieve only the UIDs of all matching index records. ```php // Inside a hook with access to the plugin $pObj: $customRequest = SearchRequest::fromContext($pObj)->withEmptySearchPhrase(); $uids = $this->searchService->searchUids($customRequest); // list<int> of tx_kesearch_index UIDs // Use $uids to load full records, build custom lists, etc. foreach ($uids as $uid) { // ... } ``` -------------------------------- ### Configure ke_search route enhancers in YAML Source: https://github.com/tpwd/ke_search/blob/master/Documentation/Configuration/RoutingSpeakingUrls.rst Defines the route path, namespace, defaults, requirements, and aspects for ke_search plugin routing. ```yaml routeEnhancers: KeSearch: type: Plugin routePath: '{sortByField}/{sortByDir}/{resetFilters}/{page}/{filter_14}/{filter_13}/{filter_3_267}/{filter_3_273}/{filter_3_278}/{filter_3_283}/{sword}' namespace: 'tx_kesearch_pi1' defaults: sortByField: 'score' sortByDir: 'desc' resetFilters: '0' page: '1' filter_13: '-' filter_14: '-' filter_3_267: '' filter_3_273: '' filter_3_278: '' filter_3_283: '' sword: '' requirements: sortByField: '(score|title|customranking)?' sortByDir: '(asc|desc)?' resetFilters: '[0-9]?' page: '\d+' filter_13: '[0-9a-zA-Z-]*' filter_14: '[0-9a-zA-Z-]*' filter_3_267: '[0-9a-zA-Z-]*' filter_3_273: '[0-9a-zA-Z-]*' filter_3_278: '[0-9a-zA-Z-]*' filter_3_283: '[0-9a-zA-Z-]*' aspects: sortByField: type: StaticValueMapper map: score: 'score' customranking: 'customranking' title: 'title' sortByDir: type: StaticValueMapper map: asc: 'asc' desc: 'desc' resetFilters: type: StaticRangeMapper start: '0' end: '1' page: type: StaticRangeMapper start: '1' end: '99' filter_13: type: KeSearchTagToSlugMapper filter_14: type: KeSearchTagToSlugMapper filter_3_267: type: KeSearchTagToSlugMapper filter_3_273: type: KeSearchTagToSlugMapper filter_3_278: type: KeSearchTagToSlugMapper filter_3_283: type: KeSearchTagToSlugMapper sword: type: KeSearchUrlEncodeMapper ``` -------------------------------- ### ke_search:indexerstatus Source: https://github.com/tpwd/ke_search/blob/master/Documentation/CommandLine/Index.rst Displays the current status of the indexer and progress if it is running. ```APIDOC ## ke_search:indexerstatus ### Description Shows the status of the indexer and if the indexer is currently running also the progress. ### Parameters #### Options - **-m, --mode** (string) - Optional - Mode, either "full" (default) or "short". Default is "full". ``` -------------------------------- ### Render result list content Source: https://github.com/tpwd/ke_search/blob/master/Resources/Private/Templates/ResultList.html Outputs additional raw content and configured text for the search results. ```html {resultListAdditionalRawContent} {conf.textForResults} ``` -------------------------------- ### Implement Conditional Template Layouts in Fluid Source: https://github.com/tpwd/ke_search/blob/master/Documentation/Templating/TemplateSelector.rst Use the conf.templateLayout variable to switch between different template sections based on the user selection. ```html <f:layout name="General"/> <f:section name="content"> <f:if condition="{conf.templateLayout}"> <f:if condition="{conf.templateLayout} == 10"> <f:render section="defaultLayout" arguments="{_all}"/> </f:if> <f:if condition="{conf.templateLayout} == 20"> <f:render section="customLayout" arguments="{_all}"/> </f:if> </f:if> </f:section> <f:section name="defaultLayout"> ... default template code </f:section> <f:section name="customLayout"> ... custom template code </f:section> ``` -------------------------------- ### Override extension configuration via TypoScript Source: https://github.com/tpwd/ke_search/blob/master/Documentation/Configuration/Notes.rst Overrides basic extension settings defined in the Admin Tools configuration. ```typoscript ke_search.extconf.override.searchWordLength = 3 ``` ```typoscript ke_search_premium.extconf.override.enableSphinxSearch = 0 ``` -------------------------------- ### Include Searchbox as a Content Element via TypoScript Source: https://github.com/tpwd/ke_search/blob/master/Documentation/Templating/Searchbox.rst Uses the RECORDS object to reference a specific content element UID. Ensure the UID matches the stored searchbox plugin configuration. ```typoscript # Include searchbox as a content element lib.searchbox = RECORDS lib.searchbox { tables = tt_content source = 7 } ``` ```typoscript page = PAGE page.5 < lib.searchbox page.10 < styles.content.get ``` ```typoscript page.5 > ``` -------------------------------- ### Create FiltersResults partial Source: https://github.com/tpwd/ke_search/blob/master/Documentation/Templating/FiltersInResultList.rst Define the partial for rendering list and custom filters in the result list. ```html <f:for each="{filters}" as="filter"> <f:switch expression="{filter.rendertype}"> <f:case value="list"><f:render partial="Filters/List" arguments="{conf: conf, filter: filter}" /></f:case> <f:case value="custom"><f:format.raw>{filter.rawHtmlContent}</f:format.raw></f:case> </f:switch> </f:for> ``` -------------------------------- ### Register the custom filter hook in ext_localconf.php Source: https://github.com/tpwd/ke_search/blob/master/Documentation/Filters/CustomFilter.rst Add this configuration to your sitepackage extension's ext_localconf.php file to register the custom filter renderer class. ```php $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['customFilterRenderer'][] = \Tpwd\KeSearchHooks\ExampleFilterRenderer::class; ``` -------------------------------- ### Format date for different locales Source: https://github.com/tpwd/ke_search/blob/master/Documentation/Templating/CustomValuesResultRow.rst Use the Fluid format.date viewhelper to display the unix timestamp resultrow.date_timestamp in a specific locale format. ```html <f:format.date format="%d. %B %Y">{resultrow.date_timestamp}</f:format.date> ``` -------------------------------- ### Register custom language overrides in ext_localconf.php Source: https://github.com/tpwd/ke_search/blob/master/Documentation/Multilingual/Index.rst Register custom translation files in your site package's ext_localconf.php to override default ke_search labels. ```typoscript // Custom translations $GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride'] ['EXT:ke_search/Resources/Private/Language/locallang_searchbox.xlf'][] = 'EXT:mysite/Resources/Private/Language/Overrides/locallang_searchbox.xlf'; // Override a German ("de") translation $GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride']['de'] ['EXT:ke_search/Resources/Private/Language/locallang_searchbox.xlf'][] = 'EXT:mysite/Resources/Private/Language/Overrides/de.locallang_searchbox.xlf'; ``` -------------------------------- ### Indexer status mode parameter Source: https://github.com/tpwd/ke_search/blob/master/Documentation/CommandLine/Index.rst Sets the output mode for the status command to full or short. ```bash -m, --mode[=MODE] Mode, either "full" (default) or "short". [default: "full"] ``` -------------------------------- ### Implement AdditionalIndexerFields class Source: https://github.com/tpwd/ke_search/blob/master/Documentation/Configuration/Sorting.rst Define the class that registers the custom field name for the indexer. ```php <?php namespace MyVendor\KeSearchHooks; /** * Class AdditionalIndexerFields * @package MyVendor\KeSearchHooks */ class AdditionalIndexerFields { public function registerAdditionalFields(&$additionalFields) { $additionalFields[] = 'mysorting'; } } ``` -------------------------------- ### Define result page via TypoScript Source: https://github.com/tpwd/ke_search/blob/master/Documentation/Configuration/Notes.rst Sets the result page ID directly or dynamically via URL parameters. ```typoscript plugin.tx_kesearch_pi1.resultPage = 9 ``` ```typoscript plugin.tx_kesearch_pi1.resultPage.data = GP:tx_kesearch_pi1|resultPage ``` -------------------------------- ### Debug available result values Source: https://github.com/tpwd/ke_search/blob/master/Documentation/Templating/CustomValuesResultRow.rst Output all available values for each result row to the template for debugging purposes. ```html <f:debug>{resultrow}</f:debug> ``` -------------------------------- ### Configure filter storage in Page TSconfig Source: https://github.com/tpwd/ke_search/blob/master/Documentation/Configuration/ReducingFiltersBackend.rst Set the storage PID to restrict filter options to a specific folder in the backend. ```typoscript tx_kesearch.filterStorage = 123 ``` -------------------------------- ### Include filters in ResultList template Source: https://github.com/tpwd/ke_search/blob/master/Documentation/Templating/FiltersInResultList.rst Render the filters partial within the ResultList template. ```html <f:if condition="{filters}"> <div class="filters filtersResults"> <f:render partial="FiltersResults" arguments="{conf: conf, numberofresults: numberofresults, resultrows: resultrows, filters: filters}" /> </div> </f:if> ``` -------------------------------- ### SearchService::search(SearchRequest $request): SearchResult Source: https://github.com/tpwd/ke_search/blob/master/Documentation/PublicSearchApi/Index.rst Executes a search based on the provided request parameters and returns a paginated SearchResult object. ```APIDOC ## SearchService::search ### Description Executes a search using the provided SearchRequest object. This method returns a SearchResult containing paginated results and the total count. ### Method PHP Method ### Signature `public function search(SearchRequest $request): SearchResult` ### Parameters - **$request** (SearchRequest) - Required - A value object containing search parameters such as searchWord, startingPoints, filters, and pagination settings. ``` -------------------------------- ### Trigger custom rendering Source: https://github.com/tpwd/ke_search/blob/master/Documentation/Filters/CustomFilter.rst Set the rendertype to 'custom' and provide the rendered HTML content to the filterData array to bypass standard ke_search rendering. ```php $filterData['rendertype'] = 'custom'; $filterData['rawHtmlContent'] = $view->render(); ``` -------------------------------- ### Indexer indexing mode parameter Source: https://github.com/tpwd/ke_search/blob/master/Documentation/CommandLine/Index.rst Defines the indexing mode as either full or incremental. ```bash -m, --indexingMode[=INDEXINGMODE] Indexing mode, either "full" (default) or "incremental". [default: "full"] ``` -------------------------------- ### Register Template Layout in Page TSconfig Source: https://github.com/tpwd/ke_search/blob/master/Documentation/Templating/TemplateSelector.rst Add a new option to the template layout selector in the plugin configuration. ```typoscript TCEFORM { tt_content { pi_flexform.ke_search_pi1.view.templateLayout.addItems { 20 = Custom search box 1 } } } ``` -------------------------------- ### Register hooks in ext_localconf.php Source: https://github.com/tpwd/ke_search/blob/master/Documentation/Indexing/IndexerTypes/CustomContentFields.rst Register the necessary hooks for modifying page content fields and content from content elements. ```php // Register hooks for indexing additional fields. $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['modifyPageContentFields'][] = \MyVendor\KeSearchHooks\AdditionalContentFields::class; $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['modifyContentFromContentElement'][] = \MyVendor\KeSearchHooks\AdditionalContentFields::class; ``` -------------------------------- ### Create FiltersForm partial Source: https://github.com/tpwd/ke_search/blob/master/Documentation/Templating/FiltersInResultList.rst Define the partial for rendering select and checkbox filters in the search form. ```html <f:for each="{filters}" as="filter"> <f:switch expression="{filter.rendertype}"> <f:case value="select"><f:render partial="Filters/Select" arguments="{conf: conf, filter: filter}" /></f:case> <f:case value="checkbox"><f:render partial="Filters/Checkbox" arguments="{conf: conf, filter: filter}" /></f:case> </f:switch> </f:for> ``` -------------------------------- ### Access original database row variables Source: https://github.com/tpwd/ke_search/blob/master/Documentation/Templating/CustomValuesResultRow.rst Access UID, PID, and specific database fields from the original record using the resultrow object. ```none {resultrow.orig_uid} {resultrow.orig_pid} {resultrow.orig_row.uid} {resultrow.orig_row.title} [...] ``` -------------------------------- ### Include Searchbox as a Plugin via TypoScript Source: https://github.com/tpwd/ke_search/blob/master/Documentation/Templating/Searchbox.rst Configures the search plugin directly in TypoScript. Note that this method does not support FlexForm-based filters. ```typoscript # Include searchbox as a plugin lib.searchbox_plugin = COA lib.searchbox_plugin { 10 < plugin.tx_kesearch_pi3 # result page 10.resultPage = 123 # CSS file 10.cssFile = EXT:ke_search/Resources/Public/Css/ke_search_pi1.css # Content element (search box plugin) from which additional # configuration should be loaded (UID of content element). # Important: If you have two search boxes on your result page # (eg. in the top and in the left area), you should set this value! # 10.loadFlexformsFromOtherCE = 123456 } ``` ```typoscript page = PAGE page.5 < lib.searchbox_plugin page.10 < styles.content.get ``` ```typoscript page.5 > ``` -------------------------------- ### Register additional sorting fields hook Source: https://github.com/tpwd/ke_search/blob/master/Documentation/Configuration/Sorting.rst Register the hook in ext_localconf.php to include custom fields in the index table. ```php // in ext_localconf.php: // Register hook to register additional fields in the index table $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['registerAdditionalFields'][] = \MyVendor\KeSearchHooks\AdditionalIndexerFields::class; ``` -------------------------------- ### searchUids(SearchRequest $request) Source: https://github.com/tpwd/ke_search/blob/master/Documentation/PublicSearchApi/Index.rst Executes a search query using the configured filters and context, returning a list of UIDs without pagination or full row data. ```APIDOC ## searchUids(SearchRequest $request) ### Description Runs the search with the same filters and context as the frontend but without pagination. Returns a list of UIDs from the tx_kesearch_index table. ### Method PHP Method ### Parameters - **$request** (SearchRequest) - Required - The search request object containing filters and context. ### Returns - **array** (list<int>) - A list of matching UIDs. ``` -------------------------------- ### kesearch:link Source: https://github.com/tpwd/ke_search/blob/master/Documentation/Templating/LinkViewHelper.rst A Fluid ViewHelper to generate links to search result pages with support for search words, filters, and custom attributes. ```APIDOC ## ViewHelper: <kesearch:link> ### Description Generates a link to a search result page. It supports passing search words, filter configurations, and standard HTML attributes. ### Parameters - **page** (integer) - Optional - The target page ID. - **piVars** (array) - Optional - Plugin variables including sword, filter[...], page, sortByField, sortByDir, and resetFilters. - **resetFilters** (array) - Optional - Filters to reset. - **keepPiVars** (boolean) - Optional - Whether to keep existing piVars. - **uriOnly** (boolean) - Optional - If true, returns only the URI string instead of a full anchor tag. - **section** (string) - Optional - Anchor for the link. - **Universal Attributes** (string) - Optional - Standard HTML attributes like class, dir, id, lang, style, title, accesskey, tabindex, onclick. ### Usage Example ```html <kesearch:link page="85" piVars="{sword: 'elephants'}" class="my-link-class">Search for elephants</kesearch:link> <kesearch:link page="85" piVars="{sword: 'elephants', filter_13: 'page', filter_3_278: 'syscat92'}">Advanced Search</kesearch:link> ``` ``` -------------------------------- ### Configure tt_news single-view page behavior Source: https://github.com/tpwd/ke_search/blob/master/Documentation/Indexing/IndexerTypes/TtNews.rst Sets the TypoScript constant to enable the use of single-view pages defined by news categories. ```typoscript plugin.tt_news.useSPidFromCategory = 1 ``` -------------------------------- ### Exclude search parameters in ext_localconf.php Source: https://github.com/tpwd/ke_search/blob/master/Documentation/Configuration/Avoid404Error.rst Add custom search word parameters to the excludedParameters array to prevent validation errors when using non-default search parameters. ```php // to be used in ext_localconf.php $GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash']['excludedParameters'] = array_merge( $GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash']['excludedParameters'], [ 'q', // e.g. if "plugin.tx_kesearch_pi1.searchWordParameter = q" ] ); ``` -------------------------------- ### Update SearchForm.html for speaking URLs Source: https://github.com/tpwd/ke_search/blob/master/Documentation/Configuration/RoutingSpeakingUrls.rst Required template adjustments including namespace declaration, URL rewriting script, and hidden field conditions. ```html <html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" xmlns:kesearch="http://typo3.org/ns/Tpwd/KeSearch/ViewHelpers" data-namespace-typo3-fluid="true"> ``` ```html <f:comment> // Replace the URL with the speaking URL </f:comment> <f:format.raw><script type="text/javascript">history.replaceState(null,'','</f:format.raw><kesearch:link keepPiVars="1" uriOnly="1" /><f:format.raw>');</script></f:format.raw> ``` ```html <f:if condition="{page}"> <input id="kesearchpagenumber" type="hidden" name="tx_kesearch_pi1[page]" value="{page}" /> </f:if> <input id="resetFilters" type="hidden" name="tx_kesearch_pi1[resetFilters]" value="0" /> <f:if condition="{sortByField}"> <input id="sortByField" type="hidden" name="tx_kesearch_pi1[sortByField]" value="{sortByField}" /> </f:if> <f:if condition="{sortByDir}"> <input id="sortByDir" type="hidden" name="tx_kesearch_pi1[sortByDir]" value="{sortByDir}" /> </f:if> ``` -------------------------------- ### Search for phrases Source: https://github.com/tpwd/ke_search/blob/master/Documentation/Behaviour/Options.rst Use double quotes to search for an exact phrase. ```none "french cooking" ``` -------------------------------- ### Fix code style Source: https://github.com/tpwd/ke_search/blob/master/README.rst Automatically fix code style according to TYPO3 guidelines. ```bash .Build/bin/php-cs-fixer fix ``` -------------------------------- ### Repair the search index table Source: https://github.com/tpwd/ke_search/blob/master/Documentation/Configuration/SearchWordLength.rst Execute this SQL command to re-index content after modifying the search word length settings. ```sql REPAIR TABLE tx_kesearch_index QUICK; ``` -------------------------------- ### Search with conjunctions Source: https://github.com/tpwd/ke_search/blob/master/Documentation/Behaviour/Options.rst Use + to require a word and - to exclude a word. Requires Sphinx.enableInWordSearch to be disabled in premium versions. ```none "french cooking" +eggs ``` ```none +"french cooking" +eggs ``` ```none "french cooking" -eggs ``` -------------------------------- ### Include filters in SearchForm template Source: https://github.com/tpwd/ke_search/blob/master/Documentation/Templating/FiltersInResultList.rst Render the filters partial within the SearchForm template. ```html <f:if condition="{filters}"> <div class="filters filtersForm"> <f:render partial="FiltersForm" arguments="{conf: conf, numberofresults: numberofresults, resultrows: resultrows, filters: filters}" /> </div> </f:if> ``` -------------------------------- ### Display error message Source: https://github.com/tpwd/ke_search/blob/master/Resources/Private/Templates/ResultList.html Outputs the error variable if present in the template context. ```html {error} ``` -------------------------------- ### Configure result type icons Source: https://github.com/tpwd/ke_search/blob/master/Documentation/Templating/Images.rst Use TypoScript to override the default icon for a specific record type in the result list. ```typoscript plugin.tx_kesearch_pi2.resultListTypeIcon.page.file = EXT:mysite/Resources/Public/Images/example-icon.png ``` -------------------------------- ### Define the custom filter Fluid template Source: https://github.com/tpwd/ke_search/blob/master/Documentation/Filters/CustomFilter.rst Create a Fluid template to define the custom HTML structure for the filter, such as using radio buttons. ```html <fieldset> <legend>Custom filter</legend> <div id="{filter.id}"> <f:for each="{filter.options}" as="option"> <input type="radio" name="{filter.name}" value="{option.value}" {f:if(condition: '{option.selected}', then: 'checked')} /> {option.title}<f:if condition="{option.selected} == ''"><f:if condition="{filter.shownumberofresults} && {option.results}"> ({option.results})</f:if></f:if><br /> </f:for> </div> </fieldset> ``` -------------------------------- ### ResultRow HTML Template Source: https://github.com/tpwd/ke_search/blob/master/Resources/Private/Partials/ResultRow.html Displays the search result details using Fluid view helpers for localization. ```html {resultrow.number}. {resultrow.title} _{f:translate(key: 'LLL:EXT:ke_search/Resources/Private/Language/locallang_searchbox.xlf:label_resulturl')}:_ {resultrow.url} _{f:translate(key: 'LLL:EXT:ke_search/Resources/Private/Language/locallang_searchbox.xlf:label_date')}:_ {resultrow.date_timestamp} _{f:translate(key: 'LLL:EXT:ke_search/Resources/Private/Language/locallang_searchbox.xlf:label_tags')}:_ {resultrow.tags} {resultrow.teaser} ``` -------------------------------- ### Disable MySQL Stopword File Source: https://github.com/tpwd/ke_search/blob/master/Documentation/Behaviour/Stopwords.rst Set the ft_stopword_file variable to an empty string to disable the default MySQL stopword list. ```none ft_stopword_file = "" ``` -------------------------------- ### Display result count information Source: https://github.com/tpwd/ke_search/blob/master/Resources/Private/Partials/PageBrowser.html Displays the range of results currently shown and the total number of results using localized labels. ```html {f:translate(key: 'LLL:EXT:ke_search/Resources/Private/Language/locallang_searchbox.xlf:results')} {pagination.startRecordNumber} {f:translate(key: 'LLL:EXT:ke_search/Resources/Private/Language/locallang_searchbox.xlf:until')} {pagination.endRecordNumber} {f:translate(key: 'LLL:EXT:ke_search/Resources/Private/Language/locallang_searchbox.xlf:of')} {numberofresults} ``` -------------------------------- ### Include Searchbox via Plain HTML Source: https://github.com/tpwd/ke_search/blob/master/Documentation/Templating/Searchbox.rst Embeds a custom form directly into the page template using the TEXT object. The action attribute must point to the slug of the search result page. ```typoscript # Include searchbox as plain HTML lib.searchbox_html = TEXT lib.searchbox_html.value ( <form method="get" id="form_kesearch_searchfield" name="form_kesearch_searchfield" action="/search/"> <input type="text" id="ke_search_searchfield_sword" name="tx_kesearch_pi1[sword]" placeholder="Your search phrase" /> <input type="submit" id="ke_search_searchfield_submit" alt="Find" /> </form> ) # Default PAGE object: page = PAGE page.5 < lib.searchbox_html page.10 < styles.content.get ``` -------------------------------- ### Unset default CSS via TypoScript Source: https://github.com/tpwd/ke_search/blob/master/Documentation/Templating/Css.rst Use this TypoScript configuration to prevent the default CSS file from loading for the specified plugins. ```typoscript plugin.tx_kesearch_pi1.cssFile > plugin.tx_kesearch_pi2.cssFile > ``` -------------------------------- ### Configure searchWordParameter in TypoScript Source: https://github.com/tpwd/ke_search/blob/master/Documentation/Configuration/SearchWordParameter.rst Use this configuration to change the default search word parameter to a custom value like 'query'. ```typoscript plugin.tx_kesearch_pi1.searchWordParameter = query ``` -------------------------------- ### Display search word length error Source: https://github.com/tpwd/ke_search/blob/master/Resources/Private/Templates/ResultList.html Renders a localized error message when the search word length does not meet requirements. ```html {f:translate(key: 'LLL:EXT:ke_search/Resources/Private/Language/locallang_searchbox.xlf:searchword_length_error', arguments: {0: extConf.searchWordLength})} ``` -------------------------------- ### SearchService::searchUids(SearchRequest $request): array Source: https://github.com/tpwd/ke_search/blob/master/Documentation/PublicSearchApi/Index.rst Executes a search and returns only the UIDs of the matching index records, bypassing pagination. ```APIDOC ## SearchService::searchUids ### Description Runs a search with the same logic as the standard search but returns only an array of matching tx_kesearch_index UIDs. This is more efficient as it does not perform pagination. ### Method PHP Method ### Signature `public function searchUids(SearchRequest $request): array` ### Parameters - **$request** (SearchRequest) - Required - A value object containing search parameters. ``` -------------------------------- ### Update Checkbox.html filter options Source: https://github.com/tpwd/ke_search/blob/master/Documentation/Configuration/RoutingSpeakingUrls.rst Adjust the name attribute for checkbox filter options to support routing. ```html <input type="checkbox" name="{option.key}" id="{option.id}" value="{option.tag}" {f:if(condition: '{option.selected}', then: ' checked="checked"')} {f:if(condition: '{option.disabled}', then: 'disabled = "disabled"')} /> ``` -------------------------------- ### Clear the search index Source: https://github.com/tpwd/ke_search/blob/master/Documentation/CommandLine/Index.rst Truncates the index table to remove all records. ```bash vendor/bin/typo3 ke_search:clearindex ``` -------------------------------- ### Remove indexer lock Source: https://github.com/tpwd/ke_search/blob/master/Documentation/CommandLine/Index.rst Clears the lock file to allow the indexer to run again if it was interrupted. ```bash vendor/bin/typo3 ke_search:removelock ``` -------------------------------- ### ke_search:clearindex Source: https://github.com/tpwd/ke_search/blob/master/Documentation/CommandLine/Index.rst Clears all records from the index by truncating the table. ```APIDOC ## ke_search:clearindex ### Description Clears all records from the index (truncates the table). ``` -------------------------------- ### Override highlighted word HTML with TypoScript Source: https://github.com/tpwd/ke_search/blob/master/Documentation/Configuration/HighlightedWord.rst Use this configuration to change the default span tag to a mark tag for highlighted search results. ```typoscript plugin.tx_kesearch_pi2.highlightedWord_stdWrap.wrap = <mark>|</mark> ``` -------------------------------- ### ke_search:removelock Source: https://github.com/tpwd/ke_search/blob/master/Documentation/CommandLine/Index.rst Removes the lock that prevents the indexer from running multiple times simultaneously. ```APIDOC ## ke_search:removelock ### Description Removes the lock which prevents the indexer from running multiple times at the same time. ```