1

Anyone getting “The action you have requested is invalid." On a search results page when using {exp:search:search_results} tag?

This is EE 2.7.3.

**Fixed --- Basically use a completely separate template for results don't try and route it through /search/index.php.

  • Are you getting that message when navigating to the search results page, or after submitting the search form? – Low Feb 26 '14 at 10:19
  • Just when I try view the template using the tag "{exp:search:search_results}" (even when there is absolutely nothing in between that and the closing tag), I do get the same result after submitting the form. – joe Feb 26 '14 at 10:32
2

The native search module, and in this case the exp:search:search_results tag, expects a URL like this, assuming the tag is put in the search/results template:

domain.com/search/results/HASH

The hash is supposed to be at least 32 characters long (alphanumeric). If the hash is not there, the error is triggered.

The hash is used to look up a submitted search query. The query has been put in the DB by submitting the search form, after which it redirects to the results page. The search hash stays valid for a limited amount of time, after which it's deleted from the DB. If EE cannot find the search query associated with the hash, the error is triggered.

If a valid query is found, it is run again. If it then has 0 results, the error is triggered.

Then there's the possibility of having an expired XID token, as a result of the secure forms. This will be addressed in 2.8, but in the meantime, you can execute this query to avoid this issue:

UPDATE exp_actions SET csrf_exempt = 1 WHERE class = 'Search';

So, make sure all of the above conditions are met, and the error should go away.

  • Hey Mr. Low thanks for your suggestions. I had submitting secure forms off so it wasn't using that XID token, and, it was saving the search results in the DB though was just throwing that error. Turns out the solutions was much more simple. You have to use a completely separate template for the results page, and I presume it's a similar case for the no-results page. I was trying to do it with if's within the /search/index.php page. – joe Feb 26 '14 at 11:56
  • Joe, can you move your fix into an answer and accept that as correct by clicking on the checkbox to the left of the answer... – Anna_MediaGirl May 23 '14 at 17:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.