Elxis CMS Forum

Support => Elxis 4.x/5.x DEV => Topic started by: seadhna on June 06, 2014, 01:44:17

Title: second search engine?
Post by: seadhna on June 06, 2014, 01:44:17
Hi there,
is it possible to have a second search engine that is set to search only one category?
A user can select which category to search manually but in a particular category I would like to have a search engine that is already pre-set to search only that category. If I copy the search module and have the copy appear on only the category in question, this works - but it still searches the entire site by default. I have played around with Mikro and Mikro search to see if this would work but it does not address this need unfortunately. Grateful for any suggestions!
Title: Re: second search engine?
Post by: datahell on June 06, 2014, 09:00:03
Search engines are extensions like modules. You can develop your own engine or modify an existing one to work as you want. If you want to search only within a specific category hide the categories drop down list and insert a hidden field with the value of the category you want only to search into.
Title: Re: second search engine?
Post by: seadhna on June 06, 2014, 19:23:22
Of course! Works like a charm - thanks!
Title: Re: second search engine?
Post by: seadhna on June 22, 2017, 13:51:17
Hi datahell,
is there a way to exclude just one category from search? But include ALL other categories?
Title: Re: second search engine?
Post by: datahell on June 22, 2017, 20:04:30
The easiest way to make the default content search engine to exclude a specific category from search is to exclude that category from category selection drop down box. To do so do the following:

Open file components/com_search/engines/content/content.engine.php
Go to line 184:
foreach ($categories as $category) {
Add below:
if ($category['catid'] == 999) { continue; }
Change 999 with the id of the category you want to exclude from selection box.
Title: Re: second search engine?
Post by: seadhna on June 23, 2017, 10:47:24
hmm.... doesn't work? I updated to the very latest version in case that was the issue, but the unwanted category is still visible in search.
Title: Re: second search engine?
Post by: datahell on June 23, 2017, 20:18:09
The code is correct. If you still see that category then you use wrong category id. Go to admin, edit the category to see its id.
Title: Re: second search engine?
Post by: seadhna on June 27, 2017, 15:36:02
Gosh, I don't know what I'm doing wrong. I have even added all the subcategories, but the pages inside still show up in the search engine. Here is the portion of code, have I done something wrong? The category IDs are definitely correct:

      $categories = $this->getCategories();
      if ($categories) {
         $prf = '- ';
         $sfx = '';
         if ($eLang->getinfo('DIR') == 'rtl') { $prf = ''; $sfx = ' -'; }
         $options = array();
         $options[] = $form->makeOption(0, $eLang->get('ALL_CATEGORIES'));
         foreach ($categories as $category) {
            if ($category['catid'] == 8) { continue; }
            if ($category['catid'] == 38) { continue; }
            if ($category['catid'] == 39) { continue; }
            if ($category['catid'] == 40) { continue; }
            if ($category['catid'] == 52) { continue; }
            if ($category['catid'] == 54) { continue; }
            if ($category['catid'] == 59) { continue; }
            $options[] = $form->makeOption($category['catid'], $category['title']);
            if (count($category['subcategories']) > 0) {
               foreach ($category['subcategories'] as $subcat) {
                  $options[] = $form->makeOption($subcat['catid'], $prf.$subcat['title'].$sfx);
               }
            }
         }
Title: Re: second search engine?
Post by: seadhna on June 27, 2017, 15:39:45
I don't know why there is an emoji here in the code. That is the number eight.
Title: Re: second search engine?
Post by: datahell on June 27, 2017, 19:05:24
Delete cache! Open folder {repository}/cache/com_search/ and you will find in it some php files with an md5 filename. Delete them all!

Example file name: 1f3870be274f6c49b3e31a0c6728957f.php

Note: Categories list is saved in the cache folder for 12 hours. After the 12 hours have passed the file is been refreshed.
Title: Re: second search engine?
Post by: seadhna on June 29, 2017, 18:39:27
Hi datahell, that directory is already empty. Just tried the search again, the unwanted category is still showing up... Anything else you can think of?
Title: Re: second search engine?
Post by: datahell on June 30, 2017, 20:08:45
No, the instructions are correct. Except if you have given us wrong request. You want to change something else and we modify something else. The instructions I gave you are for the search engine "Content" accessible from component "Search". ( http://www.example.com/search/ )

If you want you can send me a personal message with the username/password for your site's FTP to do that for you.
Title: Re: second search engine?
Post by: seadhna on July 06, 2017, 12:28:05
Thanks datahell, I will PM you now.
Title: Re: second search engine?
Post by: datahell on July 06, 2017, 23:28:18
Done! The instructions were correct but you had applied them wrong (in subcategories). Also these instructions would hide unwanted categories from category selection drop down list but keyword search would still fetch results from these categories. You hadn't told me that you don't want that. I modified the content search engine and now it works as you want. Test it.
Title: Re: second search engine?
Post by: seadhna on July 07, 2017, 15:50:50
Brilliant! Thanks very much!
Title: Re: second search engine?
Post by: komang on July 09, 2017, 06:30:41
Hi All,

I want the search engine have an option to search all resources on my web in one click, not only by each component (content, image, hotel - IOSR, youtube).

Anyone can help me? I only have a litle knowlegde of coding, very litle.

Thanks a lot

Regards,

Komang