Topic: Disable Search for a Category

Hi,  I would like to disable Search for a particular category. The idea being that I want to use one page of my website for publication of documents in draft form that will be accessed by some users who are developing reports etc.  The trouble is that Cutenews Search will find the documents on the new page. If i could disable Search from finding any posts in a particular Category that would enable the page to be hidden.

Re: Disable Search for a Category

If we get it right, you need to perform a search that would exclude some categories from the search results. This functionality hasn't been introduced yet, but you can use this "trick":

   // Check category (exclude for search)
   if ($item['c']) {
       $categories = explode(',', $item['c']);
    if (isset($category_exclude) && array_intersect($categories, $category_exclude)) {
        continue;
       }
   }

in the search.php file before the line

  $MB = function_exists('mb_strtolower');

Before

include 'search.php'

set the parameter

$category_exclude = '1,2,3,4'

(numbers are the ones for the categories to be excluded from the search results). If you insert

$category_exclude = ''

nothing will be excluded, if

$category_exclude = '1'

then the news with category '1' will be excluded (the numbers for the categories can be checked in the admin panel under the categories tab).

Best regards,
CN Support team

Re: Disable Search for a Category

Thanks I'll try that and post back

4 (edited by edwards 2018-05-01 19:54:11)

Re: Disable Search for a Category

Hi I have added the code and get a blank screen.  There was a missing semicolon in the original code that I added. I am using Cutenews 2002. I did copy and paste so the code should be ok.

Re: Disable Search for a Category

It may be that the code is not compatible with the version you are using. Please indicate the version number of the Cutenews you are using, i.e. 2.0, 2.3, 1.3, etc.

Best regards,
CN Support team

Re: Disable Search for a Category

hi Thanks  version number 2.0.2 build ID-202

Re: Disable Search for a Category

Hello edwards.  Yes, your version is may be not compatible or sported for which code you are using.

Re: Disable Search for a Category

edwards wrote:

hi Thanks  version number 2.0.2 build ID-202

We appologize for the code. It misses ";" and the version 2.0.2 is compatible with it.

The corrected code:
You should use the code below instead of the one above

// Check category (exclude for search)
               if ($item['c']) {
                   $categories = explode(',', $item['c']);
                   $_categoryex = explode(',', $category_exclude);
                   if (isset($category_exclude) && array_intersect($categories, $_categoryex)) {
                       continue;
                   }
               }
Best regards,
CN Support team

Re: Disable Search for a Category

Hi Thanks Support. All working fine !

10 (edited by khui9 2018-09-15 11:07:25)

Re: Disable Search for a Category

Support_Team wrote:
edwards wrote:

hi Thanks  version number 2.0.2 build ID-202

We appologize for the code. It misses ";" and the version 2.0.2 is compatible with it.

The corrected code: bk experience

You should use the code below instead of the one above

// Check category (exclude for search)
               if ($item['c']) {
                   $categories = explode(',', $item['c']);
                   $_categoryex = explode(',', $category_exclude);
                   if (isset($category_exclude) && array_intersect($categories, $_categoryex)) {
                       continue;
                   }
               }

This worked perfectly, Thanks support team.

11 (edited by iraleksandrova1992 2018-10-27 07:54:15)

Re: Disable Search for a Category

I disabled the search settings inside the category settings but that did not help removing it completely.

So what I did was to copy the default template and edit the category html file.