Forum Index
RegisterSearchFAQMemberlistUsergroupsLog in
How to limit the search to certain categories

 
Reply to topic    Forum Index » FAQ View previous topic
View next topic
How to limit the search to certain categories
Author Message
FI-DD
Admin


Joined: 22 Sep 2005
Posts: 2736
Location: Germany

Post How to limit the search to certain categories Reply with quote
With this little hack you can define which categories you want to search in.



It seems this hack only works using MySQL.



Open search.php and find this:

Code:
$where[] = 'and';




add below:

Code:
   $allowed_categories = array("1", "2", "3"); //Enter the categories you want to search in



   foreach($allowed_categories as $single){

      $where[] = 'category =~ %'.$single.'%';

      $where[] = 'or';

   }

   

   $count = count($where)-1;

   unset ($where[$count]);

      

   foreach ($allowed_categories as $k => $v){

         for ($i = 0; $i < 10; $i++){

            if (!in_array($v.$i, $allowed_categories)){

               $where[] = 'and';

               $where[] = 'category !~ %'.$v.$i.'%';

            }



            if (!in_array($i.$v, $allowed_categories)){

               $where[] = 'and';

               $where[] = 'category !~ %'.$i.$v.'%';

            }

         }

      }

   $where[] = 'and';




Change the first line of this code by adding the IDs of your categories.
Wed Jul 19, 2006 6:41 pm View user's profile Send private message
Guest








Please login to hide the ads.

Display posts from previous:    
Reply to topic    Forum Index » FAQ All times are GMT + 1 Hour
Page 1 of 1

 
Jump to: 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum



Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Music Lyrics.