Extension talk:Multi-Category Search

Thumbnails
If you set the $wgCategoryMagicGallery to true Mediawiki can display thumbnails of images within a category. Would it be possible for this extension to do the same? --38.99.130.13 14:29, 14 January 2009 (UTC)water2009


 * I'm not sure, but I think not. --CodeMonk 12:48, 29 January 2009 (UTC)

What about something similar to the standard search results in MediaWiki that display thumbnails? (Great extension by the way!)--38.99.130.13 15:30, 7 April 2009 (UTC)water2009

Wildcards
It would be great if Wildcards could be included. It would work best if your extension could include the Extension:Wildcard search which could be more advanced later. --Subfader 14:32, 28 February 2008 (UTC)

Ignore only search
When you only enter a category name in the ignore section it asks to enter a word in the include section. That's useless. It should be possible to list pages not in a certain category or in combination. --Subfader 18:01, 28 February 2008 (UTC)
 * I still think it would be useful to enable Ignore Only search as it might be useful to list all articles except those in a certain category (on other wikis at least). --Subfader 18:40, 13 May 2008 (UTC)
 * Yes, it would be useful. It just needs a separate SQL query, I'll add it as soon as I have time to. --CodeMonk 00:52, 13 June 2008 (UTC)
 * It is done now. --CodeMonk 01:45, 23 June 2008 (UTC)

Suggestions for improvement
Nice extension, but I see room for improvement. A few suggestions:


 * The extension lists only articles that are directly in the specified categories. It would be very useful if there was a possibility to include subcategories of the specified categories into the search. Currently, if I have a category "software" and a subcat "text editors", all articles contained in "text editors" will not be found if I search in "software"! That's not what one would expect...
 * Currently, if you type more than 1 category, the extension searches for articles that are contained in all of these categories. It would be nice if there were a way to search for articles in either category (which is a logical OR instead of the current logical AND). It would be even nicer if one would be able to combine these things into a kind of logical expression ("categoryA AND categoryB OR categoryC), but that's probably a step too far (and less likely to be needed).
 * It would be nice if there was a possibility to filter the result with a keyword search (like the standard search tool) and then present the results subdivided into title matches and text matches.

That's it for the moment, if I think of more I'll mention it here. Lexw 07:32, 17 April 2008 (UTC)
 * I doubt the devs read this page. --Subfader 16:26, 20 April 2008 (UTC)
 * I doubt they don't. The extension is still quite new, so they should be curious for comments. Lexw 07:11, 21 April 2008 (UTC)

Sorry, except a few small issues, I don't plan to expand functionality of Multi-Category Search extension in the near future. --CodeMonk 20:13, 2 May 2008 (UTC)
 * Told ya. So no need to report bugs? Like var $paramsPassMethod = 'get'; +  not working? --Subfader 17:53, 10 May 2008 (UTC)
 * What's wrong with it? --CodeMonk 20:03, 10 May 2008 (UTC)
 * Can't get it working so that the search terms are in the URL as get should do. var $paramsPassMethod = 'get'; doesn#t work since  is set per default. Nonetheless, changing it to method='get' doesn't help either. --Subfader 21:40, 12 May 2008 (UTC)
 * Are you sure you're using the unmodified latest version? It is paramsPassMethod}' action='{$action}'> there and it works well on my setup. What happens when you submit search form with 'get'? --CodeMonk 22:34, 12 May 2008 (UTC)
 * Ok I was still on 1.01. It works fine now and the drop downs are really useful!! -Subfader 17:37, 13 May 2008 (UTC)

Reset setting on result page
After hitting Search the drop down menues fall back to any. It would be ace if the selected settign would still be there as in the text input boxes. --Subfader 18:14, 13 May 2008 (UTC)


 * Fixed in 1.31. --CodeMonk 00:45, 13 June 2008 (UTC)

Category OR Category
It would be useful to be able to connect multiple categories in one 'ShownOption1InList1' => 'CategoryName1', e.g. o create a time range: '1990's' => '1990' OR '1991' OR '1992' OR '1993' ... OR '1999' --Subfader 17:44, 13 May 2008 (UTC)

autolist subcategories
Instead of creating long lists manually e.g. for a "Year" drop down:

'(any)' => '',

'2008' => '2008',

'2007' => '2007',

'2006' => '2006', ...

It would be usful to list all subcategories from a defined category automatically:

'(any)' => '',

'SubCatsOf:' => 'Year',

which would list all years available in the dropdown. This solve the major problem that you need to update the definition everytime a new ctategory is created matching your drop down criteria (which mostly is the main category of those) :) --Subfader 17:49, 13 May 2008 (UTC)

autolist categories
If you want to automatically show the list of all categories in drop down lists, use this code in MultiCategorySearch_body.php instead of manually filling the categories. // Associative array of drop-down list that read categories list from DB

$listOptions['1'] = array('(any)' => ''); $cat="cat_title"; $dbr = wfGetDB( DB_SLAVE ); $res = $dbr->select("category",$cat); while ( $row = $dbr->fetchObject( $res ) ) { $listOptions['1'][$row->$cat]=$row->$cat; } $dbr->freeResult( $res ); $listOptions['2']=$listOptions['1']; $listOptions['3']=$listOptions['1']; Yedidia 05:58, 25 May 2009 (UTC)

Extension request: Search this category
I'll try again :) From this extension it shouldn't be a long way to enable a simple search box that will be displayed on top of "every" category page. It searches like the standard search (title and content), but it only considers articles in the according category. There are two options:
 * per default on all* category pages (but where to place it on the page?)
 * via parser tag to be added individually (requires effort adding, looks useless on small categories)

Can't decide which I'd prefer, at least it should appear in the upper left corner of the category page using divs and float:left

It should look like this (without Search button): clicking into it will remove the text (as the grey font already lets you assume), hitting return will start the search action. Results should be displayed like the standard search cos of Title / Page results.


 * "every" should be adjustable in teh template, e.g. display the search box on every category page with more than 5 or 10 articles. --Subfader 17:37, 13 May 2008 (UTC)


 * I don't have enough time for that, sorry. --CodeMonk 23:37, 13 May 2008 (UTC)

Hits per page limit
Since it only lists the article names which makes 2 rows of articles (at least in my config), you should enable overriding the user's "Hits per page:" from my preferences. E.g. I have set 40 there and the result here is 2x20 which looks ok, but I think default is 20 = 2x10 which is way to less and the user will def browse further or change the limit. --Subfader 18:37, 13 May 2008 (UTC)


 * I designed output in 3 columns. Are you sure there are only 2? --CodeMonk 01:45, 23 June 2008 (UTC)


 * Well, I hacked /include/CategoryPage.php to do only list 2 columns --Subfader 05:13, 23 June 2008 (UTC)

Download is broken
Hi there, could you please fix the download please!? --Ozz 18:28, 28 July 2008 (UTC)


 * It's not broken. Maybe there was a temporary problem. Try again. --CodeMonk 23:28, 28 July 2008 (UTC)

Warnings when loading Special:MultiCategorySearch 1.35
Just hitting the page:

Notice: Undefined offset: 1 in /var/www/html/w/extensions/MultiCategorySearch/MultiCategorySearch_body.php on line 237 Notice: Undefined offset: 2 in /var/www/html/w/extensions/MultiCategorySearch/MultiCategorySearch_body.php on line 237 Notice: Undefined offset: 3 in /var/www/html/w/extensions/MultiCategorySearch/MultiCategorySearch_body.php on line 237 Notice: Undefined offset: 4 in /var/www/html/w/extensions/MultiCategorySearch/MultiCategorySearch_body.php on line 237 Notice: Undefined offset: 5 in /var/www/html/w/extensions/MultiCategorySearch/MultiCategorySearch_body.php on line 237 Notice: Undefined offset: 1 in /var/www/html/w/extensions/MultiCategorySearch/MultiCategorySearch_body.php on line 248 Notice: Undefined offset: 2 in /var/www/html/w/extensions/MultiCategorySearch/MultiCategorySearch_body.php on line 248 Notice: Undefined offset: 3 in /var/www/html/w/extensions/MultiCategorySearch/MultiCategorySearch_body.php on line 248

After a search:

Notice: Undefined variable: fname in /var/www/html/w/extensions/MultiCategorySearch/MultiCategorySearch_body.php on line 83 Notice: Undefined property: MultiCategorySearch::$title in /var/www/html/w/extensions/MultiCategorySearch/MultiCategorySearch_body.php on line 185 Notice: Undefined variable: fname in /var/www/html/w/extensions/MultiCategorySearch/MultiCategorySearch_body.php on line 207

--Maiden taiwan 14:17, 23 March 2009 (UTC)


 * Sorry, it was a minor bug in that version. Please, download version 1.36 or set "error_reporting = E_ALL & ~E_NOTICE" in settings in your php.ini file to disable insignificant PHP notices. --CodeMonk 03:22, 26 March 2009 (UTC)

I've got this problem myself on MW 1.15.1 with extention version 1.40. After poking about in the PHP docs a little, I came up with thie possibly inelegant patchlet to stop the complains. (I picked NULL as a fill value because that's what you get when the notices happen and obviously the code worked fine with them then :)). --- MultiCategorySearch_body.orig.pgp  2010-03-11 13:02:26.386125000 -0500 +++ MultiCategorySearch_body.php    2010-03-11 13:16:56.276750000 -0500 @@ -57,6 +57,9 @@

parent::__construct( $name ); list( $this->limit, $this->offset ) = $wgRequest->getLimitOffset( 100, 'searchlimit' ); +      // WEAVER: Pre-size arrays to stop undefined offsets +      $this->inCategories = array_fill(1, $this->inCategoriesNumber, NULL); +      $this->exCategories = array_fill(1, $this->exCategoriesNumber, NULL); }   function MultiCategorySearch { global $wgRequest; --WeaverThree 18:25, 11 March 2010 (UTC)

function MultiCategorySearch { global $wgRequest;

SpecialPage::SpecialPage( 'MultiCategorySearch' ); list( $this->limit, $this->offset ) = $wgRequest->getLimitOffset( 100, 'searchlimit' ); +		// WEAVER: Pre-size arrays to stop undefined offsets +             $this->inCategories = array_fill(1, $this->inCategoriesNumber, NULL); +            $this->exCategories = array_fill(1, $this->exCategoriesNumber, NULL); }

function execute( $par ) { global $wgRequest, $wgOut, $wgVersion;

if( version_compare( $wgVersion, '1.8', '<' ) === true ) { $wgOut->showErrorPage( "Error: Upgrade required", "The News Channel extension " .				"can't work on MediaWiki version older than 1.8. Please, upgrade." ); return; }

$gotres = false; if( strlen($par) > 0 ) { $par = preg_replace('/\/(..)clude=/','|\1clude=',$par); $bits = explode( '|', trim( $par ) ); $in = 1; $ex = 1; // clear out old parameters...wonkified behavior results if not $this->inCategories = array; $this->exCategories = array; +          // WEAVER: Pre-size arrays to stop undefined offsets +           $this->inCategories = array_fill(1, $this->inCategoriesNumber, NULL); +           $this->exCategories = array_fill(1, $this->exCategoriesNumber, NULL); foreach ( $bits as $bit ) { $bit = trim( $bit ); $type = substr($bit,0,8); if ( 'include=' == $type ) { $this->inCategories[$in] = substr($bit,8); $in++; } else if ( 'exclude=' == $type ) { $this->exCategories[$ex] = substr($bit,8); $ex++; }			}		} else if( !is_null( $wgRequest->getVal( 'wpSubmitSearchParams' ) ) ||			stripos( $wgRequest->getRequestURL, 'wpInCategory' ) !== false ||			stripos( $wgRequest->getRequestURL, 'wpExCategory' ) !== false) { for( $i = 1; $i <= $this->inCategoriesNumber; $i++ ) $this->inCategories[$i] = $wgRequest->getVal( 'wpInCategory' . $i ); for( $i = 1; $i <= $this->exCategoriesNumber; $i++ ) $this->exCategories[$i] = $wgRequest->getVal( 'wpExCategory' . $i ); }		$this->showResults; if ( !$this->including ) $this->showForm; }
 * Error-control for these arrays was enhanced. --CodeMonk 01:50, 17 January 2012 (UTC)

Checkbox support
It would be awsome, if you could use checkboxes for every section instead of the drop down list, so that users can click on more than one category, something like...

Option 1

[ ] Category1 [ ] Category2 [x] Category3 [ ] Check/Uncheck all

Option 2

[x] Category4 [x] Category5 [ ] Category6 [ ] Check/Uncheck all

and so on...

Is it difficult to change source code to support something like that? It would be fantasctic...

Integrate this into Mediawiki!
Such a functionality should be integrated in Mediawiki itself. Or is there another possibility to search for example for a "female physican from ghana" in wikipedia? -- Beyer 09:09, 15 June 2009 (UTC)

Checkbox for including subcategories
Is it possible to enhance this extension to include all subcategories of the choosen categories in the search? -- Beyer 11:09, 18 June 2009 (UTC)
 * It's a huge task. I don't see efficient way to handle category trees inside MediaWiki right now. --CodeMonk 01:34, 17 January 2012 (UTC)

Transclusion and Memcached support
Since I'm impatient, I went ahead and wrote the following public domain patch to implement transclusion and dynamic memcached support since the queries are sometimes heavy-handed. I sent this to the author as well for inclusion in the next release. Transclusions can be performed like so:

The patch is a little too big to be pasted here. You can get it from my server.


 * Possible error:
 * When I click on Search with the latest version of Special:MultiCategorySearch it returns a HTML page with just The memcached server displayed. Looking at the code, this appears to be related to your patch in MultiCategorySearch_body.php.
 * MW: 1.15.1
 * PHP: 5.2.9
 * MySQL: 5.0.77
 * Hosted on Siteground
 * GarethLewis 23:40, 3 February 2010 (UTC)


 * Transclusion and Memcached support is available since version 1.4. --CodeMonk 01:40, 17 January 2012 (UTC)

Sort
It will be nice to sort articles like wiki do (with capital first letter from title) I will try to do that soon
 * It was implemented in version 1.62. --CodeMonk 01:37, 17 January 2012 (UTC)

CategoryIntersection
Who ever tried it? Is it works? Extension:CategoryIntersection
 * I didn't try it. --CodeMonk 01:24, 17 January 2012 (UTC)

Results to include pages in a category's sub category
I want category searches to give pages that are included in the sub categories of a category as well.

I have a page for instance in the three categories: Category: Generation 1 Category: G1 Blue Category: G1 Unicorn

(Just category blue and category unicorn got too big)

Then category G1 Unicorn is a subcategory of Generation 1 and Unicorn And G1 Blue is a sub category of also Generation 1 and then Blue

I would really like to multi category search for Generation 1 and Unicorn and Blue and have it work. That the page in the categories: Category: Generation 1 Category: G1 Blue Category: G1 Unicorn

will come up...

thanks, absol


 * It's a huge task. I don't see efficient way to handle category trees inside MediaWiki right now. --CodeMonk 01:32, 17 January 2012 (UTC)

My Special Page looks all messed up.. Any help?
Hello I installed this extension, but my special page looks all messed up and I don't see instructions on how to use this extension. Can anyone help me?

MediaWiki 	1.15.4 PHP 	5.1.6 (apache2handler) MySQL 	5.0.77

I'm trying to attach an image but I can't attach a pic of what I'm seeing in the special pages.

More information: Something is messed up with the i18n'ed strings. They don't show up until wfShowingResults has been called at least once (I don't know what this function does). So hitting the page the first time, or displaying a page with no search results, will not show the localized strings correctly. I stuck in a call to wfShowingResults in execute before results are displayed, and this sort of works. But when you log in as a user, then i18n does not work at all (with or without my attempted fix).
 * No ideas, sorry. But you can try version 1.62, wfShowingResultsNum function was reimplemented in it. --CodeMonk 01:19, 17 January 2012 (UTC)

1.62 doesn't seem to work proper with dropdown menues
I don't know how to say better, but it doesn't seem to work proper when using dropdown menues. (1) the number of categories in the dropdown menues seems soemhow limited. (2) the search results from search within dropdown menus differ from search results when typing the categories by hand. and if you allow (3) configuration of the drop down menues isn't easy (while i am sure to have set their configuration right, i have used older versions of this extension before and also did configure them for my needs). Please check the functionality from within the dropdown menues. A fixed version of this great extension would be highly appreciated. Schmelzle 19:27, 23 January 2012 (UTC)

Another Bug for 1.62: the bold text of the numbers of search results is not displayed bold, instead the three apostrophes are visible left and right of the number of results. Schmelzle 19:30, 23 January 2012 (UTC)

I am also having the same issue with the dropdown menu not showing all the categories in the list when I use the array to list them. Drew


 * (1) There really is a limit. No more than 100 subcategories are listed by default. You can increase that number in $subCategoriesLimit = 100 variable on line 371 (as of version 1.62). (2) It would be a serious bug if search results from within dropdown menus are abnormal, but I was unable to reproduce that. Please, give me a link so I could investigate it. (3) I don't see any way to ease dropdown lists configuration. Any ideas would be appreciated. (4) You can try commenting out lines 221,222,223 and uncommenting lines 224,225,226 (as of version 1.62) if you see that 1 thing. And tell me if it works for you. --CodeMonk (talk) 03:42, 17 March 2012 (UTC)

Many Thanks - I increased the subcategory limits and commented out lines 221,222,223. Fixed both my issues -- Drew Stampstudy (talk) 08:11, 18 May 2012 (UTC)

Combining Drop down array and manual category
I have run into a small problem :

I used both dropdown lists and the additional manual category. When I perform a search using both at the same time the results appear but the manual entry changes to the first dropdown menu choice.

Example: http://www.stampsoftheworld.co.uk/wiki/Special:MultiCategorySearch


 * Choose Alderney as the country in the first dropdown
 * Type in Military in the first category box and hit "Find my stamps!"
 * 3 entries should appear which is correct but the manual entry now changes from Military to Alderney.

Many thanks for any help Stampstudy (talk) 09:18, 22 May 2012 (UTC)


 * I fixed that in version 1.63. I have also changed drop-down lists configuration system. Please, tell me if you like it. --CodeMonk (talk) 19:34, 23 May 2012 (UTC)

Fatal error after upgrading to Mediawiki 1.19.0
After upgrading to Mediawiki 1.19.0 I get the following fatal error on pages using MultiCategorySearch 1.63


 * Fatal error: Cannot redeclare prepareStrForDb (previously declared in /my-path-to-wiki/extensions/MultiCategorySearch/MultiCategorySearch_body.php:148) in /my-path-to-wiki/extensions/MultiCategorySearch/MultiCategorySearch_body.php on line 148

If I do not activate error_reporting in the LocalSettings.php the page just stays white. The extension was running perfectly fine before the upgrade.

Many thanks for any help Elaiel (talk) 23:44, 12 June 2012 (CEST)


 * Do you wish to transclude MCS more than once on a single page? --CodeMonk (talk) 01:52, 13 June 2012 (UTC)
 * Yes, I use this as an "advanced" category page Elaiel (talk) 10:36, 13 June 2012 (CEST)
 * Ok, I've made necessary changes. Try version 1.64. --CodeMonk (talk) 21:22, 13 June 2012 (UTC)
 * Works perfectly! Thanks! Elaiel (talk) 12:57, 14 June 2012 (CEST)

Transclude the Special Page and Sort Order of Results
Is there any way to transclude the special page with the drop down menus onto another page? and almost all of our pages have a sort key when added to their main category is there anyway to display the results using this sort key rather than alphabetically. Stampstudy (talk) 08:20, 29 August 2012 (UTC)
 * Transclusion format is mentioned on extension's page. There is currently no way to determine "main" category, so there is no way to sort pages by key. --CodeMonk (talk) 11:23, 29 August 2012 (UTC)
 * Thank you for the prompt reply - I read the transclusion options but I was looking to transclude the special page including the dropdowns and not the results of a search using something like . Thank you for the information regarding the sort key. Stampstudy (talk) 11:31, 30 August 2012 (UTC)
 * Currently there is no such feature. --CodeMonk (talk) 02:57, 31 August 2012 (UTC)

Text fields at page top?
On the search results page, I want to move the entry fields from page bottom to page top. How can I do this? --Rogerhc (talk) 03:39, 24 October 2012 (UTC)
 * You should change the following code fragment in MultiCategorySearch_body.php file:


 * for the following code fragment:


 * --CodeMonk (talk) 01:38, 27 October 2012 (UTC)

Transclusion
In using this extension, I've found that while it's possible to transclude a results page from Special:MultiCategorySearch, I can't transclude the search page itself (doing so creates an internal error), which is what I'd like it to do. :-) Is it possible to change this in the code already installed in the extension subdirectory? Thanks in advance, Rock drum (talk · contribs) 20:20, 16 November 2012 (UTC)


 * Yes, it's possible. You should change the following code fragment in MultiCategorySearch_body.php file:


 * for the following code fragment:


 * And the following code fragment in MultiCategorySearch_body.php file:


 * for the following code fragment:


 * --CodeMonk (talk) 03:58, 17 November 2012 (UTC)
 * Hmm, this still doesn't let me tranclude  on a page in Vector. Is it also possible for the search boxes to have some sort of "predictive search", such as is provided in Extension:Vector? Regards, Rock drum (talk · contribs) 13:34, 18 November 2012 (UTC)
 * I've updated the solution. Try it. Predictive search is not implemented. --CodeMonk (talk) 17:23, 18 November 2012 (UTC)
 * Thanks. It allows the page to be transcluded now but adds  before all of the section headings on the page, with the 1 being substituted for the number of the heading... Rock drum (talk · contribs) 17:39, 19 November 2012 (UTC)
 * That's very strange. I have no idea what could have happened to the headings. Please, revert the changes. --CodeMonk (talk) 00:14, 20 November 2012 (UTC)
 * I wonder if you ever got this to work Rock drum? Being able to transclude the actual search page would be great for my site. --Stampstudy (talk) 12:16, 18 June 2013 (UTC)

PHP Fatal error: Call to undefined function wfLoadExtensionMessages
I have placed the latest version 1.64 on my media wiki server version 1.21.0 and I am getting this error when I try to load any page "PHP Fatal error: Call to undefined function wfLoadExtensionMessages in /var/www/mediawiki-1.21.0/extensions/MultiCategorySearch/MultiCategorySearch_body.php on line 59" after I added require_once("$IP/extensions/MultiCategorySearch/MultiCategorySearch.php"); to my LocalSettings.php file. Any advice? --70.162.122.10 06:09, 29 May 2013 (UTC)
 * I've made a new version 1.65 to suit MediaWiki 1.21. Try it. --CodeMonk (talk) 11:03, 31 May 2013 (UTC)

Checkboxes
I was asked how the checkboxes could be made for choosing categories. Here is an example: \n"); }