diff --git a/typo3/sysext/core/Documentation/Changelog/master/Feature-82070-ExcludeDoktypesInSearchResult.rst b/typo3/sysext/core/Documentation/Changelog/master/Feature-82070-ExcludeDoktypesInSearchResult.rst new file mode 100644 index 0000000000000000000000000000000000000000..1dd1851ef52b6e39972f6d1bb19fdf3897609a3c --- /dev/null +++ b/typo3/sysext/core/Documentation/Changelog/master/Feature-82070-ExcludeDoktypesInSearchResult.rst @@ -0,0 +1,60 @@ +.. include:: ../../Includes.txt + +============================================================================ +Feature: #82070 - Exclude doktypes in path of search result (indexed_search) +============================================================================ + +See :issue:`82070` + +Description +=========== +After submitting the search form in Indexed Search, the search results are displayed. +Each search result displays a "path" and contains the page tree structure. +In the structure, system folders can be used, which actually can't be excluded when the path is rendered. +Similar to "hide in menu" or "RealUrl exclude from path segment", there should be a configuration to exclude doktypes +from the path render business logic. + +Page tree structure: +[SysFolder] Footer -> [SysFolder] Navigation -> [Page] Imprint + +Output in Indexed Search without :php:`pathExcludeDoktypes` settings: +:php:`/Footer/Navigation/Imprint` + +Output in Indexed Search with :php:`pathExcludeDoktypes` settings: +:php:`/Imprint` + + +Examples +~~~~~~~~ + +Exclude single doktype +********************** + +sys_folder (doktype: 254) + +.. code-block:: typoscript + + plugin.tx_indexedsearch { + settings { + results { + pathExcludeDoktypes = 254 + } + } + } + +Exclude multiple doktypes +************************* + +sys_folder (doktype: 254) and shortcuts (doktype:4) + +.. code-block:: typoscript + + plugin.tx_indexedsearch { + settings { + results { + pathExcludeDoktypes = 254,4 + } + } + } + +.. index:: Frontend, ext:indexed_search, TypoScript diff --git a/typo3/sysext/indexed_search/Classes/Controller/SearchController.php b/typo3/sysext/indexed_search/Classes/Controller/SearchController.php index 56012789a64ac465c65ed69e92d023870fa5a7c1..2711e4ee3094748d376142b36f2a28d40854e658 100644 --- a/typo3/sysext/indexed_search/Classes/Controller/SearchController.php +++ b/typo3/sysext/indexed_search/Classes/Controller/SearchController.php @@ -1408,10 +1408,18 @@ class SearchController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControlle $path = ''; $pageCount = count($rl); if (is_array($rl) && !empty($rl)) { + $excludeDoktypesFromPath = GeneralUtility::trimExplode( + ',', + $this->settings['results']['pathExcludeDoktypes'] ?? '', + true + ); $breadcrumbWrap = isset($this->settings['breadcrumbWrap']) ? $this->settings['breadcrumbWrap'] : '/'; $breadcrumbWraps = GeneralUtility::makeInstance(TypoScriptService::class) ->explodeConfigurationForOptionSplit(['wrap' => $breadcrumbWrap], $pageCount); foreach ($rl as $k => $v) { + if (in_array($v['doktype'], $excludeDoktypesFromPath, false)) { + continue; + } // Check fe_user if ($v['fe_group'] && ($v['uid'] == $id || $v['extendToSubpages'])) { $this->requiredFrontendUsergroups[$id][] = $v['fe_group']; diff --git a/typo3/sysext/indexed_search/Configuration/TypoScript/setup.txt b/typo3/sysext/indexed_search/Configuration/TypoScript/setup.txt index 92bbbdeef6390c780b573fa5c2dc01a2ad4a8865..e0e1dec11ed9cc07dd0774af9a6e22b8912b4327 100644 --- a/typo3/sysext/indexed_search/Configuration/TypoScript/setup.txt +++ b/typo3/sysext/indexed_search/Configuration/TypoScript/setup.txt @@ -49,6 +49,7 @@ plugin.tx_indexedsearch { markupSW_postPreLgd_offset = 5 markupSW_divider = ... markupSW_divider.noTrimWrap = | | | + pathExcludeDoktypes = } # Blinding of option-selectors / values in these (advanced search) diff --git a/typo3/sysext/indexed_search/Documentation/Configuration/TypoScript/Index.rst b/typo3/sysext/indexed_search/Documentation/Configuration/TypoScript/Index.rst index ef8073c3c640d4bb202a118d59a1542db1439017..cee60334b9992eb3a4c9aecca593ef590dbf8a6e 100644 --- a/typo3/sysext/indexed_search/Documentation/Configuration/TypoScript/Index.rst +++ b/typo3/sysext/indexed_search/Documentation/Configuration/TypoScript/Index.rst @@ -603,6 +603,33 @@ results\_markupSW_divider Divider for highlighted searchwords in the summary Defaults to "..." +.. _results-pathExcludeDoktypes: + +results\_pathExcludeDoktypes +"""""""""""""""""""""""""""" + +.. container:: table-row + + Property + results\_pathExcludeDoktypes + + Data type + string + + Description + Excludes doktypes in path. + Defaults to "" + + **Example:** + pathExcludeDoktypes = 254 + Exclude sys_folder (doktype: 254) in path for result. + + "/Footer(254)/Navi(254)/Imprint(1)" -> "/Imprint". + + pathExcludeDoktypes = 254,4 + Exclude sys_folder (doktype: 254) and shortcuts (doktype:4) in path for result. + "/About-Us(254)/Company(4)/Germany(1)" -> "/Germany". + .. _linkSectionTitles-stdWrap: