Score:1

/search-results page returns 404 if no query parameter is present

sm flag

I have inherited a Drupal site with a node that uses /search-results as path alias.

The page works fine if I use https://example.com/search-results?keys=test or https://example.com/search-results?keys, but it returns a 404 error if I use https://example.com/search-results.

Any thoughts on where to begin?

Score:0
nz flag

How do you process the parameter? Is there a module to look at it? or you do it in your .theme hooks?

In any case you wanna try to set a default respose for the function you are using to process that key parameter.

user110161 avatar
sm flag
That is a very good question. I've checked the .theme and didn't see anything. There is a search api module installed which I am not familiar with. The search form (on all pages) has an action for '/search-result', on that page, it says it is for an override of main view template and it uses 'exposed.keys' with comment: "exposed: Exposed widget form/info to display." From there, i cannot see why this page would end up with a 404 error if that query parameter is not included.
Pipo Bizelli avatar
nz flag
Did you know if ther's a view named `search-results` or something like that?
user110161 avatar
sm flag
this is what i can see: there is a template in the theme named: page--search-result.html.twig it contains an embed view (set in the .theme file) named views-view--search-content.html.twig. if that embedded view is commented out in the page--search-result.html.twig the page will load (obviously without any results) as soon as it is added back in, the 404 occurs even if nothing is on that embedded page.
user110161 avatar
sm flag
it looks like it is using a built in filter Views->Search Content -> FILTER CRITERIA Configure filter criterion: Search: Fulltext search has 'keys' as the Filter identifier
Pipo Bizelli avatar
nz flag
In this configuration, did you see any `CONTEXTUAL FILTERS` under the `ADVANCED` tab?
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.