We are updating an ancient TYPO3 project, we already run on TYPO3 9.5 and it's looking good after a lot of refactoring.
Now I rework the ext:indexed_search
section which got implemented into the T3Core (sysext:indexed_search). So if I disable/remove my site configuration, the search just works out of the box. Once I enable our default site configuration, holding:
base: 'ourDomain'
baseVariants:
-
base: 'ourDomain'
condition: 'applicationContext == "Development"'
-
base: 'ourDomain'
condition: 'applicationContext == "Testing"'
errorHandling: { }
languages:
-
title: Deutsch
enabled: true
base: /
typo3Language: de
locale: de_DE
iso-639-1: de
navigationTitle: Deutsch
hreflang: de-DE
direction: ''
flag: at
languageId: '0'
rootPageId: 1
routes: { }
routeEnhancers:
The search does not work properly anymore. I can navigate to the search page and still have the search form and stuff but no results are shown. I'm dumping $search
inside SearchController and saw that it's actually empty no matter what.
After some research, I thought the RouteEnhancer configuration could be the problem, so I added some configuration to the site cfg
routeEnhancers:
IndexedSearchPlugin:
type: Extbase
limitToPages:
- 41
extension: IndexedSearch
plugin: Pi2
routes:
- routePath: '/search'
_controller: 'Search::search'
defaultController: 'Search::search'
So as child of our root-page we have a page called "Suche"(route=/suche) which holds the indexed_search
plugin.
So the RouteEnhancer should work like domain.at/suche -> hit search -> /suche/search results, right? It seems like everything works but the data from the search input field is just missing... so there are no results.
I cannot get this to work for quite some time now, help is much appreciated.
a missing trailing slash in the form action was the problem. because without that slash a user would get redirected while loosing POST data.
solution:
.htaccess:
#redirect urls without slash
RewriteCond %{REQUEST_URI} /+[^\.]+$
RewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [R=301,L]
site configuration:
routeEnhancers:
IndexedSearchPlugin:
type: Extbase
limitToPages:
- 41
extension: IndexedSearch
plugin: Pi2
routes:
- routePath: '/search'
_controller: 'Search::search'
defaultController: 'Search::search'
PageTypeSuffix:
type: PageType
default: '/'
index: ''
map:
'/': 0