P
P
Pavel Kizernis2015-09-17 13:11:40
Joomla
Pavel Kizernis, 2015-09-17 13:11:40

The standard Joomla search does not work on the homepage (with &Itemid=101), but works without "&Itemid=101". How to fix?

Version of Joomla: 3.4
I display the search through the standard module for all pages.
if you enter "word" on the main site.ru, then the URL will be:

http://site.ru/component/search/?searchword=слово&searchphrase=all&Itemid=101

but the search results are not visible, but the main page template is visible.
But if you remove " Itemid=101 " from the URL, i.e. So:
http://site.ru/component/search/?searchword=слово&searchphrase=all

then the search results are visible.
If you go to http://site.ru/component/search/
and enter "word" there, the URL will become:
http://site.ru/component/search/?searchword=слово&ordering=newest&searchphrase=all

search results are visible. there are no folders like "com_search" or "mod_search"
in the folder /templates/theme_name/html In the file /components/com_search/views/search/view.opensearch.php I see the following code
if (isset($items[0]))
{
  $searchUri .= '&Itemid=' . $items[0]->id;
}

tried to add
if (isset($items[0])) {
  if ($items[0]->id != 101) { /* remove "Itemid=101" from url for main page */
    $searchUri .= '&Itemid=' . $items[0]->id;
  }
}

but it didn't help (I tried checking for both 101 and "101")... I
managed to remove "&Itemid=101" via JS:
var url = window.location.href;
if(url.indexOf("&Itemid=101") > -1) {
  url = url.replace("&Itemid=101", "");
  window.location.replace(url);
}

But not very happy with the extra page reload...
Can someone explain why this happens, and how to properly solve this problem so that the search results are displayed everywhere?
Or, to be precise, that of course there is nowhere to display them on the main page (in the template), which means you need a redirect to site.ru/component/search?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2015-09-17
@pashakiz

Try making a hidden menu item for search

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question