[FEATURE] Exclude doktypes in path of search result 71/53671/3
authorJörg Bösche <typo3@joergboesche.de>
Thu, 10 Aug 2017 11:32:20 +0000 (13:32 +0200)
committerJan Helke <typo3@helke.de>
Thu, 23 Nov 2017 15:49:51 +0000 (16:49 +0100)
The search result has a path with the pagetree structure.
It must be possible to exclude doktypes from the path.

Releases: master
Resolves: #82070
Change-Id: I15d6bb0765aa237ab86cb75e6ffff0c26d8f504d
Reviewed-on: https://review.typo3.org/53671
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Reviewed-by: Frans Saris <franssaris@gmail.com>
Tested-by: Frans Saris <franssaris@gmail.com>
Reviewed-by: Tobi Kretschmann <tobi@tobishome.de>
Reviewed-by: Jan Helke <typo3@helke.de>
Tested-by: Jan Helke <typo3@helke.de>
typo3/sysext/core/Documentation/Changelog/master/Feature-82070-ExcludeDoktypesInSearchResult.rst [new file with mode: 0644]
typo3/sysext/indexed_search/Classes/Controller/SearchController.php
typo3/sysext/indexed_search/Configuration/TypoScript/setup.txt
typo3/sysext/indexed_search/Documentation/Configuration/TypoScript/Index.rst

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 (file)
index 0000000..1dd1851
--- /dev/null
@@ -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
index 5601278..2711e4e 100644 (file)
@@ -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'];
index 92bbbde..e0e1dec 100644 (file)
@@ -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)
index ef8073c..cee6033 100644 (file)
@@ -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: