Extension talk:Multi-Category Search
Add topicThumbnails
[edit]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
[edit]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
[edit]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)
- 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)
Suggestions for improvement
[edit]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'; + <form id='MultiCategorySearch' method='get' action='{$action}'> 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 <form id='MultiCategorySearch' method='post' action='{$action}'> 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 <form id='MultiCategorySearch' method='{$this->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)
- 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 <form id='MultiCategorySearch' method='post' action='{$action}'> is set per default. Nonetheless, changing it to method='get' doesn't help either. --Subfader 21:40, 12 May 2008 (UTC)
- What's wrong with it? --CodeMonk 20:03, 10 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)
Drop down options
[edit]Reset setting on result page
[edit]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
[edit]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
[edit]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
[edit]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
[edit]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
[edit]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
[edit]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
[edit]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
[edit]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!
[edit]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
[edit]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
[edit]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:
{{Special:MultiCategorySearch/include=foo/exclude=bar}}
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
[edit]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
[edit]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
[edit]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?
[edit]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
[edit]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
[edit]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
[edit]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)
Transclude the Special Page and Sort Order of Results
[edit]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 {{Special:MultiCategorySearch}}. 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)
- 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 {{Special:MultiCategorySearch}}. Thank you for the information regarding the sort key. Stampstudy (talk) 11:31, 30 August 2012 (UTC)
Text fields at page top?
[edit]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:
$this->showResults();
if( !$this->including() )
$this->showForm();
- for the following code fragment:
if( !$this->including() )
$this->showForm();
$this->showResults();
Transclusion
[edit]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:
if( !$this->including() )
- for the following code fragment:
if( strlen( $par ) === 0 )
- And the following code fragment in MultiCategorySearch_body.php file:
} else if( !is_null( $wgRequest->getVal( 'wpSubmitSearchParams' ) ) ||
stripos( $wgRequest->getRequestURL(), 'wpInCategory' ) !== false ||
stripos( $wgRequest->getRequestURL(), 'wpExCategory' ) !== false ) {
- for the following code fragment:
} else if( !$this->including() && (!is_null( $wgRequest->getVal( 'wpSubmitSearchParams' ) ) ||
stripos( $wgRequest->getRequestURL(), 'wpInCategory' ) !== false ||
stripos( $wgRequest->getRequestURL(), 'wpExCategory' ) !== false )) {
- --CodeMonk (talk) 03:58, 17 November 2012 (UTC)
- Hmm, this still doesn't let me tranclude
{{Special:MultiCategorySearch}}
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
?UNIQ770d549f453ff927-h-1--QINU?
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)
- 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)
- Thanks. It allows the page to be transcluded now but adds
- I've updated the solution. Try it. Predictive search is not implemented. --CodeMonk (talk) 17:23, 18 November 2012 (UTC)
- Hmm, this still doesn't let me tranclude
PHP Fatal error: Call to undefined function wfLoadExtensionMessages()
[edit]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
[edit]I was asked how the checkboxes could be made for choosing categories. Here is an example:
// a fork from 1.65
function showForm() {
global $wgOut, $wgUser, $wgRequest;
global $wgScriptPath, $wgUseAjax, $wgJsMimeType;
$wgOut->setPagetitle( wfMsg( 'multicategorysearch' ) );
$titleObj = Title::makeTitle( NS_SPECIAL, 'MultiCategorySearch' );
$action = $titleObj->escapeLocalURL( '' );
$token = htmlspecialchars( $wgUser->editToken() );
$msgComment = wfMsgHtml( 'multicatsearch_comment' );
$msgInCategories = wfMsgHtml( 'multicatsearch_include' );
$msgExCategories = wfMsgHtml( 'multicatsearch_exclude' );
$msgSubmitButton = wfMsgHtml( 'multicatsearch_submit_button' );
$dropdownLists = $this->showDropdownLists();
$dropdownListsCount = substr_count( $dropdownLists, '<select' );
$wgOut->addWikiText( $msgComment );
$wgOut->addHTML("
<br />
<form id=\"MultiCategorySearch\" method=\"{$this->paramsPassMethod}\" action=\"{$action}\">
<table border=\"0\">
{$dropdownLists}
<tr>
<td colspan=\"2\" align=\"left\">{$msgInCategories}</td>
</tr>");
$wgOut->addHTML("
<tr>
<td>category1</td>
<td><input type=\"checkbox\" name=\"wpInCategory1\" id=\"wpInCategory1\" value=\"category1\"></td>
</tr>
<tr>
<td>category2</td>
<td><input type=\"checkbox\" name=\"wpInCategory2\" id=\"wpInCategory2\" value=\"category2\"></td>
</tr>");
$wgOut->addHTML("
<tr>
<td colspan=\"2\" align=\"left\">{$msgExCategories}</td>
</tr>");
for( $i = 1; $i <= $this->exCategoriesNumber; $i++ ) {
$j = $this->inCategoriesNumber + $i;
$categoryTitle = '';
if( array_key_exists( $i, $this->exCategories ) )
$categoryTitle = $this->exCategories[$i];
$wgOut->addHTML("
<tr>
<td colspan=\"2\">
<input tabindex=\"{$j}\" type=\"text\" size=\"40\" name=\"wpExCategory{$i}\" " .
"value=\"{$categoryTitle}\" />
</td>
</tr>");
}
$j = $this->inCategoriesNumber + $this->exCategoriesNumber + 1;
$wgOut->addHTML("
<tr>
<td colspan=\"2\" style=\"padding-top: 1em\" align=\"right\">
<input tabindex=\"{$j}\" type=\"submit\" name=\"wpSubmitSearchParams\" " .
"value=\"{$msgSubmitButton}\" />
</td>
</tr>
</table>
</form>\n");
}
- Hi and thanks for all your work. For those of us who don't know PHP, how exactly does one implement the code (where does it go and does anything get replaced)? Thanks.
- It is a fragment of MultiCategorySearch_body.php file. category1 and category2 should be replaced (in 2 places each) for real category names. I'm not sure if this could be done without basic HTML and PHP knowledge, but you can try. --CodeMonk (talk) 14:55, 25 January 2014 (UTC)
Links broken or blocked
[edit]I tried the latest two build download links and the english version example link and they all came back unrecognised. Can you make the zip files available with http links rather than ftp please? That may be the issue.--Simon Oliver (talk) 11:40, 19 November 2013 (UTC)
- FTP is Ok. It must have been some temporary problem. --CodeMonk (talk) 12:31, 20 November 2013 (UTC)
Bugfix (?)
[edit]Since I was not able to format MediaWiki:Multicatsearch_comment the way I wanted to, I stumbled upon this and replaced (in MultiCategorySearch_body.php)
$msgComment = wfMsgHtml( 'multicatsearch_comment' );
with
$msgComment = wfMessage( 'multicatsearch_comment' )->text();
While on it, I also replaced all occurences of
wfMsg( 'somekey' )
and
wfMsgHtml( 'somekey' )
with
wfMessage( 'somekey' )->escaped()
Would be great if someone could let me know if this is the right thing to do.--Baumgeist (talk) 15:31, 6 October 2015 (UTC)
- What are you trying to do? How would you like Multicatsearch_comment to be formatted? --CodeMonk (talk) 05:56, 7 October 2015 (UTC)
- I'd like to be able to use wikicode in MediaWiki:Multicatsearch_comment so I can link to some other page on the wiki. The fix does this for me. The question ist: Is this the right way to do it?--Baumgeist (talk) 15:02, 7 November 2015 (UTC)
- Where messages are ouput using $wgOut->addWikiText() function it's ok to use wfMessage('message-key')->text(), otherwise use wfMessage('message-key')->parse() for wikicode ouput. wfMsgHtml('message-key') can indeed be replaced with wfMessage('message-key')->escaped(). --CodeMonk (talk) 06:14, 8 November 2015 (UTC)
- I'd like to be able to use wikicode in MediaWiki:Multicatsearch_comment so I can link to some other page on the wiki. The fix does this for me. The question ist: Is this the right way to do it?--Baumgeist (talk) 15:02, 7 November 2015 (UTC)
Strict Standards Error seen after upgrading to MW 1.26.2
[edit]I am seeing this message
Strict Standards: Only variables should be assigned by reference in /home/rulemlso/public_html/wiki.ruleml.org/extensions/MultiCategorySearch/MultiCategorySearch_body.php on line 142
when I use the form page, and also on transclusions.
I fixed this, I think, by making the following change to line 142 of MultiCategorySearch_body.php
$dbr = wfGetDB( DB_SLAVE );
- Ok, I updated the source. Try version 1.68. --CodeMonk (talk) 18:52, 30 December 2015 (UTC)
Fix to enable counting of articles
[edit]I have an update of the code that allows to display the number of article instead of a list. So it is like
{{PAGESINCAT:categoryname}}
but with several categories. It is still very hacky, but where can I push this, and where can I discuss it? It mainly allows to add "/count" in the call of Special:MultiCategorySearch to count instead of list. For example :
{{Special:MultiCategorySearch/count/include=MyCat|/exclude=Draft}}
For information, here is the code (click on "edit source" to see the code).
Thanks! --109.0.228.101 15:40, 19 January 2016 (UTC)
Not working, falls whole Mediawiki. Apache log:
PHP Parse error: syntax error, unexpected ';' in /usr/share/mediawiki/extensions/MultiCategorySearch/MultiCategorySearch_body.php on line 222
- Apache 2.4.9
- PHP 5.5.26
- Mediawiki 1.21.2
- Multicategory 1.68
Same result with extension both 1.66 and 1.69 --
Will there be an Update for MW 1.28
[edit]The extension doesn't work any more for MW 1.28. Will there be an update? 23x23x23 (talk) 13:51, 6 December 2016 (UTC)
- Yes. Thanks for reporting this. I didn't know about the problem. --CodeMonk (talk) 14:36, 6 December 2016 (UTC)
crash with $wgMemCachedServers = []
[edit]In my automatic installation, $wgMemCachedServers is set to []. That makes the extension to crash because it is not testing the variable before querrying it at MultiCategorySearch_body.php at line 50. Louperivois (talk) 22:04, 18 May 2017 (UTC)
- Affirmative. I also experienced the sudden death of the webserver when using this extension. --[[kgh]] (talk) 08:27, 21 March 2018 (UTC)
Issue with MW 1.31
[edit](Solved, see Addendum 2)
I just added Multi-Category Search to my wiki, and found that the search page setup works, but when I select a category and press Search, I get the following stack trace:
.......] /index.php?title=Special:MultiCategorySearch Error from line 144 of /home/mindmapping/www/www/extensions/MultiCategorySearch/MultiCategorySearch_body.php: Call to undefined function wfProfileIn() Backtrace: #0 /home/mindmapping/www/www/extensions/MultiCategorySearch/MultiCategorySearch_body.php(107): MultiCategorySearch- >showResults() #1 /home/mindmapping/www/www/includes/specialpage/SpecialPage.php(522): MultiCategorySearch->execute(NULL) #2 /home/mindmapping/www/www/includes/specialpage/SpecialPageFactory.php(568): SpecialPage->run(NULL) #3 /home/mindmapping/www/www/includes/MediaWiki.php(288): SpecialPageFactory::executePath(Title, RequestContext) #4 /home/mindmapping/www/www/includes/MediaWiki.php(861): MediaWiki->performRequest() #5 /home/mindmapping/www/www/includes/MediaWiki.php(524): MediaWiki->main() #6 /home/mindmapping/www/www/index.php(42): MediaWiki->run() #7 {main} The selection configuration this occurs with is very simple: // Configuration settings $dropDownList['1'] = array( '*' => '', 'ListCaption' => 'Availability', 'AutoFillFrom' => 'STATUS', 'Available & maintained' => 'Current', 'Available, no longer maintained' => 'Historical', 'No longer available' => 'Historical (defunct)', ); // End of configuration settings, don't change the script below this line
Is MultiCategorySearch known to be OK with 1.31? Thanks. --Roygrubb (talk) 16:48, 28 July 2018 (UTC)
Addendum: The site is here: https://www.mind-mapping.org/index.php?title=Special:MultiCategorySearch --Roygrubb (talk) 16:50, 28 July 2018 (UTC)
Addendum 2: I see here: https://www.mediawiki.org/wiki/Manual:Profiling that "Note: The custom MediaWiki profiling calls (wfProfileIn/wfProfileOut) are deprecated and are being progressively removed and are no-ops in MediaWiki 1.25+" so this explains the problem.
So I commented out these two lines
144 wfProfileIn( 'MultiCategorySearch::showResults' ); 311 wfProfileOut( 'MultiCategorySearch::showResults' );
and with the simple case given in my original example above, it appears to work correctly. I'll now add values for more complex searches and see if it still works. -- Roygrubb (talk) 07:23, 29 July 2018 (UTC)
MultiCategorySearch UnexpectedValueException with the new MediaWiki 1.34
[edit]Hi Iaroslav,
I'm an appreciative user of MultiCategorySearch. Thanks for your work on this important extension. It has become a feature of my site at www.mind-mapping.org.
I just updated WikiMedia to version 1.34 and had an UnexpectedValueException as follows:
[Xo7PkbmV@0j77xU6qch05AAAAAE] /index.php?title=Special:MultiCategorySearch UnexpectedValueException from line 462 of /home/mindmapping/www/www/includes/libs/rdbms/loadbalancer/LoadBalancer.php: Invalid server index index #DB_SLAVE Backtrace: #0 /home/mindmapping/www/www/includes/libs/rdbms/loadbalancer/LoadBalancer.php(896): Wikimedia\Rdbms\LoadBalancer->getConnectionIndex(string, array, string) #1 /home/mindmapping/www/www/includes/libs/rdbms/loadbalancer/LoadBalancer.php(1043): Wikimedia\Rdbms\LoadBalancer->getConnection(string, array, string, integer) #2 /home/mindmapping/www/www/includes/GlobalFunctions.php(2576): Wikimedia\Rdbms\LoadBalancer->getMaintenanceConnectionRef(string, array, string) #3 /home/mindmapping/www/www/extensions/MultiCategorySearch/MultiCategorySearch_body.php(415): wfGetDB(string) #4 /home/mindmapping/www/www/extensions/MultiCategorySearch/MultiCategorySearch_body.php(663): MultiCategorySearch->getSubCategories(string) #5 /home/mindmapping/www/www/extensions/MultiCategorySearch/MultiCategorySearch_body.php(340): MultiCategorySearch->showDropdownLists() #6 /home/mindmapping/www/www/extensions/MultiCategorySearch/MultiCategorySearch_body.php(111): MultiCategorySearch->showForm() #7 /home/mindmapping/www/www/includes/specialpage/SpecialPage.php(575): MultiCategorySearch->execute(NULL) #8 /home/mindmapping/www/www/includes/specialpage/SpecialPageFactory.php(611): SpecialPage->run(NULL) #9 /home/mindmapping/www/www/includes/MediaWiki.php(296): MediaWiki\Special\SpecialPageFactory->executePath(Title, RequestContext) #10 /home/mindmapping/www/www/includes/MediaWiki.php(900): MediaWiki->performRequest() #11 /home/mindmapping/www/www/includes/MediaWiki.php(527): MediaWiki->main() #12 /home/mindmapping/www/www/index.php(44): MediaWiki->run() #13 {main} line 462 of /home/mindmapping/www/www/includes/libs/rdbms/loadbalancer/LoadBalancer.php is throw new UnexpectedValueException( "Invalid server index index #$i" ); which is part of private function getConnectionIndex( $i, array $groups, $domain ) { if ( $i === self::DB_MASTER ) { $i = $this->getWriterIndex(); } elseif ( $i === self::DB_REPLICA ) { foreach ( $groups as $group ) { $groupIndex = $this->getReaderIndex( $group, $domain ); if ( $groupIndex !== false ) { $i = $groupIndex; // group connection succeeded break; } } } elseif ( !isset( $this->servers[$i] ) ) { throw new UnexpectedValueException( "Invalid server index index #$i" ); }
User Ammarpad told me that: "DB_SLAVE constant has been renamed and old alias removed in 1.34. You should upgrade MultiCategorySearch extension too. If after upgrade, DB_SLAVE is still there, you should file a bug report against the extension."
Will you be able to update MultiCategorySearch so that it is compatible with MW vsn. 1.34?
Thanks a lot
Roygrubb (talk) 09:04, 11 April 2020 (UTC)
- Hi Roygrubb, from reading the above discussions, it seems you already had issue with this extension when you upgraded to 1.31. (which you worked around, but probably it's still not really fixed). The author last edited in 2016 which is around the same time the extension saw its last update. Another thing is that this extension is not hosted on Wikimedia Gerrit, otherwise at least those minor deprecation stuff would have been taken care of.
There are also other unresolved issues reported by other users above, so unfortunately I marked this extension as "unmaintained" to reflect this reality.
It's unlikely for you to receive response here, so if you want use the extension with 1.34, you should try working it around by replacing instances of "DB_SLAVE" with "DB_REPLICA". But be aware that this may not necessarily works in case there are other incompatible logic. Ammarpad (talk) 11:29, 11 April 2020 (UTC)
- Hi Ammarpad, your advice has been most valuable.
- I replaced DB_SLAVE with DB_REPLICA and it moved things along, but then failed with an exception on addWikiText. Your earlier hint on DB_SLAVE being deprecated made me search for deprecation notices mentioning addWikiText, and I found this in HISTORY "Use OutputPage::addWikiTextAsInterface() or OutputPage::addWikiTextAsContent() instead, which ensures the output is tidy and clarifies whether content-language specific postprocessing should be done on the text."
- My whole site is in English and I have no prospect of other languages there, so I replaced the two references to addWikiText in MultiCategorySearch_body.php with addWikiTextAsInterface - these are the only two references to addWikiText in the three php files in MultiCategorySearch. My site now works in 1.34 and I just have to move it from a staging directory.
- Thanks for your help. I'm sure this isn't up to MediaWiki testing standards, but should I post my updated MultiCategorySearch_body.php somewhere?
- Roygrubb (talk) 14:49, 11 April 2020 (UTC)
- I don't think you need to do anything else. Happy for you that it works. Since this extension is not hosted on Wikimedia Gerrit, there's actually no place to at least fix those issues. The source code is hosted on SourceForge, which is relatively obscure. If you care for it to work for others you've to contact the author or those who have acces to modify the repository there. This MediaWiki extension page is just for informational purpose now. Ammarpad (talk) 19:11, 11 April 2020 (UTC)
- Roygrubb (talk) 14:49, 11 April 2020 (UTC)
- Thanks. I've added instructions on making the extension work in 1.34, as an "Unofficial fix" with suitable precautionary notes. It's working for me and it seems a shame to let a useful extension die. Roygrubb (talk) 10:14, 12 April 2020 (UTC)
- Thank you for your work! I'm working on a new wiki right now, using the newest MediaWiki 1.38.2, but I still get this error.
- I did all the fixes, which are on the extension site, but it still doesn't work... :-(
- This extension is VERY VERY essential for my new project. I used it years ago and it was just fantastic!
- I don't know how to go on without a multi category search...
- I can't even see my Special:Pages site!
- If MultiCategorySearch is activated in LocalSettings.php I get this error, when I try to go to Special:SpecialPages:
- Thanks. I've added instructions on making the extension work in 1.34, as an "Unofficial fix" with suitable precautionary notes. It's working for me and it seems a shame to let a useful extension die. Roygrubb (talk) 10:14, 12 April 2020 (UTC)
[30c8cb67d136a954a167a719] /index.php?title=Special:SpecialPages Error: Call to undefined method WebRequest::getLimitOffset() Backtrace: from /html/wiki/extensions/MultiCategorySearch/MultiCategorySearch_body.php(62) #0 /html/wiki/vendor/wikimedia/object-factory/src/ObjectFactory.php(247): MultiCategorySearch->__construct() #1 /html/wiki/vendor/wikimedia/object-factory/src/ObjectFactory.php(152): Wikimedia\ObjectFactory\ObjectFactory::getObjectFromSpec() #2 /html/wiki/includes/specialpage/SpecialPageFactory.php(1230): Wikimedia\ObjectFactory\ObjectFactory->createObject() #3 /html/wiki/includes/specialpage/SpecialPageFactory.php(1265): MediaWiki\SpecialPage\SpecialPageFactory->getPage() #4 /html/wiki/includes/specials/SpecialSpecialpages.php(53): MediaWiki\SpecialPage\SpecialPageFactory->getUsablePages() #5 /html/wiki/includes/specials/SpecialSpecialpages.php(42): SpecialSpecialpages->getPageGroups() #6 /html/wiki/includes/specialpage/SpecialPage.php(671): SpecialSpecialpages->execute() #7 /html/wiki/includes/specialpage/SpecialPageFactory.php(1378): SpecialPage->run() #8 /html/wiki/includes/MediaWiki.php(315): MediaWiki\SpecialPage\SpecialPageFactory->executePath() #9 /html/wiki/includes/MediaWiki.php(912): MediaWiki->performRequest() #10 /html/wiki/includes/MediaWiki.php(563): MediaWiki->main() #11 /html/wiki/index.php(53): MediaWiki->run() #12 /html/wiki/index.php(46): wfIndexMain() #13 {main}
- If I go to Special:MultiCategorySearch , the error message seems different:
[845a65daf7f801931b5f78da] /index.php?title=Special:MultiCategorySearch Error: Call to undefined method WebRequest::getLimitOffset() Backtrace: from /html/wiki/extensions/MultiCategorySearch/MultiCategorySearch_body.php(62) #0 /html/wiki/vendor/wikimedia/object-factory/src/ObjectFactory.php(247): MultiCategorySearch->__construct() #1 /html/wiki/vendor/wikimedia/object-factory/src/ObjectFactory.php(152): Wikimedia\ObjectFactory\ObjectFactory::getObjectFromSpec() #2 /html/wiki/includes/specialpage/SpecialPageFactory.php(1230): Wikimedia\ObjectFactory\ObjectFactory->createObject() #3 /html/wiki/includes/MediaWiki.php(274): MediaWiki\SpecialPage\SpecialPageFactory->getPage() #4 /html/wiki/includes/MediaWiki.php(912): MediaWiki->performRequest() #5 /html/wiki/includes/MediaWiki.php(563): MediaWiki->main() #6 /html/wiki/index.php(53): MediaWiki->run() #7 /html/wiki/index.php(46): wfIndexMain() #8 {main}
- Any solutions?
- Any other extensions which could do the same for me? :-(
- I'm really desperate at this point, because I really need something like this working. Raspuli (talk) 11:41, 7 July 2022 (UTC)
Unknown error
[edit]I installed the extension, but when I try to search, I get this error.
[YCZmDQ89WOTMKa-NwI9ouQAAAAY] /%D0%A1%D0%BB%D1%83%D0%B6%D0%B5%D0%B1%D0%BD%D0%B0%D1%8F:MultiCategorySearch Error from line 293 of /var/www/vh305318/data/www/empirespuzzles.xyz/extensions/MultiCategorySearch/MultiCategorySearch_body.php: Call to private method CategoryViewer::formatList() from context 'MultiCategorySearch' Backtrace: #0 /var/www/vh305318/data/www/empirespuzzles.xyz/extensions/MultiCategorySearch/MultiCategorySearch_body.php(107): MultiCategorySearch->showResults() #1 /var/www/vh305318/data/www/empirespuzzles.xyz/includes/specialpage/SpecialPage.php(600): MultiCategorySearch->execute(NULL) #2 /var/www/vh305318/data/www/empirespuzzles.xyz/includes/specialpage/SpecialPageFactory.php(635): SpecialPage->run(NULL) #3 /var/www/vh305318/data/www/empirespuzzles.xyz/includes/MediaWiki.php(307): MediaWiki\SpecialPage\SpecialPageFactory->executePath(Title, RequestContext) #4 /var/www/vh305318/data/www/empirespuzzles.xyz/includes/MediaWiki.php(940): MediaWiki->performRequest() #5 /var/www/vh305318/data/www/empirespuzzles.xyz/includes/MediaWiki.php(543): MediaWiki->main() #6 /var/www/vh305318/data/www/empirespuzzles.xyz/index.php(53): MediaWiki->run() #7 /var/www/vh305318/data/www/empirespuzzles.xyz/index.php(46): wfIndexMain() #8 {main}
and there are no drop-down lists in the input fields of categories. I understand that the extension is no longer supported (unfortunately) but suddenly someone will help