I have a multilingual site, with one channel and multiple fields for different languages. The site has 20+ different channels. Everything works ok, except the search results page for low_search in 2. language.
The problem is with the creation of entry urls for search results (there are several different channels in serach results)
In other templates i generate the url with code
{preload_replace:my_template_group="news/more/"}
....
<a
href="{path='{my_template_group}'}/{entry_id}/{exp:create_url_title}{title-en}{/exp:create_url_title}"
title="{title-en}"
>
{title-en}
</a>
I tried to find out in wich channel the result entry is, and then store his group name in preload_replace var. But that is not working properly. Every entry gets the group name of the first item in IF. The used code:
{exp:low_search:results
collection_lang="en"
channel="o-nama|vijesti|kontakt"
query="{segment_2}"
limit="10"
paginate="bottom"
keywords:mode="all"
keywords:loose="right"
status="open|uvodni"
require_query="yes"
}
{if low_search_no_results}
<div class="alert alert-success">
No results found for the search term
</div>
{/if}
{if channel_name == "kontakt"} {preload_replace:my_template_group="contact/"}{/if}
{if channel_name == "o-nama"} {preload_replace:my_template_group="about-us/"}{/if}
{if channel_name == "vijesti"} {preload_replace:my_template_group="news/more/"}{/if}
<h2 class="entry-title-index">
<a href="{path='{my_template_group}'}/{entry_id}/{exp:create_url_title}{title-en}{/exp:create_url_title}"
title="{title-en}"
>
{title-en}
</a>
</h2>
{/exp:low_search:results}
I tried the if with channel_name ,channel_id, channel_short_name...I always get the same result (my_template_group=contact)
It would be a good idea to store the group name in a variable, as I use the generated url in multiple places (img href, h2 title...)