Hey guys,
Now I have simple search working properly, is it possible to create a template route to change how the template is loaded?
For example, say I have this as the results template -
blog/search-results
But i’d like to change the template route to something like -
usa/search/results/6ebf3adc2fb6770a95c0dfc83e513b10/
I’ve tried something like this -
/{searchcountry:regex[(zh|cn|usa)]}/search/results/{alpha_dash}/
But it just fails and says “The action you have requested is invalid.”
Hey James,
Sure, here you go:
{exp:search:simple_form
form_class="header-search"
where="any"
search_in="everywhere"
channel="static|homepage|news_resources|case_studies"
result_page="{segment_1}/blog/search-results"
no_result_page="{segment_1}/blog/noresults"
}
<input type="text" name="keywords" id="keywords" value="" placeholder="Search...">
<input type="submit" id="search-submit" name="submit" value="">
{/exp:search:simple_form}
So as an example of the way the site works, you can access the site via something like example.com/usa/search or example.com/zh/search or example.com/cn/search. We use the first segment to control what contact information is shown.
So I tried a route like this -
/{searchcountry:regex[(zh|cn|usa)]}/search/results/{alpha_dash}/
And while it kinda tries to load the route, it always throws the error
“The action you have requested is invalid.”
Andy
Hey James,
It’s on 3.4.1. To give you an idea of the form block, here’s the HTML
I’ve replaced our live URL with example.com as I can’t post publicly, but feel free to email me - andy[at]pillorybarn.co.uk
<form class="header-search" method="post" action="http://www.example.com/" _lpchecked="1">
<div class="hiddenFields">
<input type="hidden" name="ACT" value="21">
<input type="hidden" name="RES" value="">
<input type="hidden" name="meta" value="KoT6RYQD5DBBXX3OGP+A0MqZgRAJ4R0VgqlYj7jXKdBT9I5RZbrGcdSnxv0R45YuPcUlI3k+Z2op54YjtseSJdSs2nY0RZGFVDFWUy1skSQaibj6PW0beThZrVlVLCcrwJdcPGwk9ueyHrFysAcDUYOCkL9w6OEnFaRcbTnQzj5YNDfcSP9gV+uWRW+ssC1+W+IL2JA6FYd7NczVbGLFc9+N9k7mT1iXhCs9jVFN75VOnXDVjZJm2Gvi8JDcxDwJ74UaiGd0/n8ER4V1nhhkOybHzmWRkI1mnlMyJGl5FYXtMcHKQzTjhdGVELkI30BqrV+5cIUHgVCpBOoBgY2RJSSfB+glZT6jTakY2fc7+7CqNp98+7iRQJqvvk1CqiRUZhnFA9nBj0aA+6DS5NllRH7dpvUv9mccAf5oGY/YPaDLTERHKsMmMHY+tcIuN25zoP0t6jiaV3JwAW2GSgRbnw==">
<input type="hidden" name="site_id" value="1">
<input type="hidden" name="csrf_token" value="ea0bbba7708a5d6cafbed1ca4f08f6c995ea85e6">
</div>
<input type="text" name="keywords" id="keywords" value="" placeholder="Search...">
<input type="submit" id="search-submit" name="submit" value="">
</form>
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.