Extension talk:CategoryHook

I'm having trouble with this extension. I created two category hooks for my wiki. When a page qualifies for both, it does not seem to add to the category correctly. The categories show up at the bottom of the page as edit links (despite the fact that they do have content in them) and the category itself says 0 articles.
 * Can you show me the code so I can see what you're trying to do? --Nad 08:53, 19 July 2007 (UTC)

User-friendliness
Is there an easier way to manage auto-categorization than having to dork with PHP files? I really hate dealing with them. A proper control panel special page should be created for this... -Eep² 22:15, 23 July 2007 (UTC)


 * I actually made this for the ability to use curly-brace syntax for categorisation (so that non-wikitext articles like scripts can still use categorisation) not for the auto-categorisation feature, but eventually I would like to make a better interface for categorisation rules. --Nad 22:55, 23 July 2007 (UTC)


 * OK, well, do you know of an easy way to have auto-categorization for, say, namespaces at least? So, like:


 * ...etc, preferably configurable of what the category name is (like for singular/plural at least). -Eep² 00:21, 24 July 2007 (UTC)


 * You can use DPL to query by namespace and render the results in category format --Nad 01:16, 24 July 2007 (UTC)


 * Er, huh? That's not what I'm asking. I want created articles to automatically be categorized relative to what their namespace is. DPL just lists things in categories (etc)--and it's not very user-friendly. Ideally, a GUI to enter auto-categorization rules without having to dork with PHP; akin to matching rules and the category such matches should be assigned to, preferably calling up existing categories (via MW:Extension:CategoryTree, for example) and having a radio button next to each one in order to visually select it instead of text (hence the graphical UI part). -Eep² 02:59, 24 July 2007 (UTC)


 * If you want to avoid editing files you can make the category hook run a php article which you make only accessible by sysop and keep your php categorisation code in. However, to DPL can achieve the same thing by creating articles which behave like a category page but contain the result of a query, for example, see Articles in Category namespace which dynamically contains all the current articles in the "Category" namespace. DPL is the main reason I didn't really end up using the categorisation rules. --Nad 04:18, 24 July 2007 (UTC)


 * Well, now we're back to the DPL user-unfriendliness issue if I'm going to have to use DPL throughout my entire site in order to get what I want... Is there at least a list of common queries (like, at least to simulate existing MediaWiki functions)? -Eep² 05:11, 24 July 2007 (UTC)

What kinds of queries do you want? most of the standard mediawiki-like functionality would be like selecting articles belonging to particular namespaces or categories or with titles matching certain patterns etc, eg: category=foo namespace=bar titlematch=%baz% those parameters would select all articles in "foo" category having namespace "bar" and having "baz" in their title. Output format is set to a bullet list by default, but can be made like a category list as in the Articles in Category namespace example, or can include aspects of the article content or generate reports through templates etc. --Nad 06:16, 24 July 2007 (UTC)


 * I want queries that can build this game comparison table as specified here. -Eep² 06:57, 24 July 2007 (UTC)

That looks like a cool project, I think for generating that kind of table DPL is currently the best solution that MediaWiki has, also SemanticMediaWiki. SMW has more sophisticated querying ability, but DPL has better reporting. The key thing when adding structured data to a wiki for use in these ways is to use template syntax, the same way the extension template in this article is done, eg.

That way you can put all the data in without worrying about implementation which is added to the template definiations. Even all the catgeorisation links should be done from within the templates based on the passed parameters rather than being put directly into the individual game articles. Semantic relations can be placed in the templates too which allows the items to be selected in sophisticated ways such as all games between 1980 and 1990.


 * Yea, I'm using Semantic Forms to create forms for game entries, but it's very crude at the moment. I just need to know how to use DPL to get a table of the various fields. -Eep² 08:14, 24 July 2007 (UTC)


 * Extension:TemplateTable is a lot easier to use but, unfortunately, it isn't very complex. :/ -Eep² 14:03, 24 July 2007 (UTC)


 * See http://semeb.com/dpldemo/index.php?title=DPL_talk:Manual_-_DPL_parameters:_Controlling_output_format for DPL issues with trying to get template-specified category links to appear in tables; it's just not working... -Eep² 05:42, 27 July 2007 (UTC)

Can't wait
Well, I can't wait until you decide to make this easier to use so I'm biting the bullet and going to try it. However, I don't even know where to put the rules--LocalSettings.php? -Eep² 07:17, 6 August 2007 (UTC)
 * It's just a normal hook, just add the code straight after the include statement in localsettings. --Nad 22:21, 6 August 2007 (UTC)


 * OK, I've elaborated that on the extension's page. Now, how would I automatically add pages in namespaces to their appropriate categories? -Eep² 04:06, 7 August 2007 (UTC)

How "visible" is it while creating a new article?
Before I waste time installing and trying; This would be very useful for me only when it adds defined keywords of existing categories as

at the end of the edit field already in preview mode and not as "surprise" after saving. So if word or phrase exists as category > add as category. Is that possible? --89.59.161.204 18:18, 19 August 2007 (UTC)
 * I'm not quite sure what you're wanting to know exactly, could you explain in more detail what you're wanting to use it for? --Nad 22:32, 19 August 2007 (UTC)

Problems implementing mediawiki 1.11.0
First of all some code faults:

line# 84 removed '}' line# 98 or 99 added '}'

After changeing these minor flaws I could'nt get this extension up and running. There seem to be problems with wfCatHookLanguageGetMagic.

I'm not quite familiar with mediawiki code so any help would be more then appreciated!

Error: Warning: call_user_func_array [function.call-user-func-array]: First argument is expected to be a valid callback, 'wfCatHookLanguageGetMagic' was given in .../wiki/includes/Hooks.php on line 113

Kaspera 16:39, 6 November 2007 (UTC)
 * You need to put the braces back how they were, those last two functions are global and don't belong in the class definition. I have it working properly on other 1.11's, what was the problem that was occurring before you made the change? --Nad 21:29, 6 November 2007 (UTC)


 * I got unintended header output that messed up the stylesheets. The server doesn't throw errors though, working on how to get the debugger working... I guess the output must be WebResponse.php and some headers allready sent, output started at x.php at line 1.
 * Kaspera 09:05, 7 November 2007 (UTC)

Warning: Cannot modify header information - headers already sent by (output started at /var/www/dev/intranet/wiki/extensions/CategoryHook.php:1) in /var/www/dev/intranet/wiki/includes/RawPage.php on line 133

Warning: Cannot modify header information - headers already sent by (output started at /var/www/dev/intranet/wiki/extensions/CategoryHook.php:1) in /var/www/dev/intranet/wiki/includes/RawPage.php on line 136


 * After disabling all other hooks and extensions, I get this message:

Notice: Use of undefined constant SFH_NO_HASH - assumed 'SFH_NO_HASH' in /var/www/dev/intranet/wiki/extensions/CategoryHook.php on line 33


 * Kaspera 09:52, 7 November 2007 (UTC)


 * The latter case is 'solved' by setting a 'hard' 1 instead of the constant value.

Anyhow, I still get the RawPage.php error: (only visible in my FireFox Errorconsole) (dutch) Fout: invalid flag after regular expression Bronbestand: http://pad/dev/intranet/wiki/index.php?title=-&action=raw&smaxage=0&gen=js&useskin=monobook Regel: 2, Kolom: 11 Broncode: Warning: Cannot modify header information - headers already sent by (output started at /var/www/dev/intranet/wiki/extensions/CategoryHook.php:1) in /var/www/dev/intranet/wiki/includes/RawPage.php on line 133


 * Kaspera 10:07, 7 November 2007 (UTC)
 * The SFH_NO_HASH is one of the mediawiki defined constants, if it's not defined it shows a problem with your mediawiki installation. The headers-sent problem may be white-space at the end of the script, the easiest fix for that is to remove the php closing delimiter. --Nad 21:56, 7 November 2007 (UTC)

doesn't work until refresh
If page is saved when category just added to it, #ifcat fails to find it (parser functions probably work before category information is saved into the database). Once page is purged everything shows up correctly.

I wonder if there is a workaround for this.

Bugzilla and version control
I wonder if you're planning to use some sort of bug tracking tool (e.g. http://bugzilla.mediawiki.org/) and if you're going to have version control as well - either MediaWiki's SVN or a project hosted on http://code.google.com/hosting/