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


 * Now such upgrade is not scheduled, sorry. --CodeMonk 22:14, 22 April 2009 (UTC)

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; }

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)

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)

Sort
It will be nice to sort articles like wiki do (with capital first letter from title) I will try to do that soon

CategoryIntersection
Who ever tried it? Is it works? Extension:CategoryIntersection