[Mediawiki-l] Category listing with hierarchal view?
Vina Wang
vwang at myrealbox.com
Thu Dec 16 23:28:35 UTC 2004
One of the bot in the bot suite with the interwiki bot has the capability to show the category tree under a specific category.
The page http://meta.wikimedia.org/wiki/Interwiki_bot/Getting_started gives you direction to get the bot (in Python). The page doesn't mention it, but one of the script that you get is category.py which has a tree generation mode. The page generated will be displayed nicely, but will of course be static and need periodic refreshes.
-Vina
-----Original Message-----
From: Brion Vibber <brion at pobox.com>
To: MediaWiki announcements and site admin list <mediawiki-l at Wikimedia.org>
Date: Wed, 15 Dec 2004 16:43:52 -0800
Subject: Re: [Mediawiki-l] Category listing with hierarchal view?
On Dec 15, 2004, at 4:24 PM, Lisa Jill wrote:
> I have recently set up MediaWiki to use as an information repository.
> I am interested in using the Categories page as a table of contents.
>
> However, to do this effectively, I would like to do two things.
>
> 1) Have Special:Categories show a hierarchal view of categories, witih
> top level categories and sub-categories indented underneath.
That would be a really handy thing to have. We don't have this yet
mainly because extracting a tree from the link graph is not very
efficient, particularly on a large site like Wikipedia.
It would probably though be fairly easy to generate a tree by walking
through the links table; you probably would want to cache the tree data
and regenerate it periodically. (And make sure you don't get caught by
loops...)
Each entry in the categorylinks table links a page (by cur_id index
number) to a category (by name). Pages in the NS_CATEGORY namespace
(cur_namespace=14) are themselves categories, and their category
memberships denote child->parent relationships. So basically you'll
want to pull all the category memberships:
SELECT cur_title,cl_to
FROM cur,categorylinks
WHERE cur_namespace=14 AND cur_id=cl_from
and work out a tree of subcategory memberships from that. There is no
default root node, and there is no a priori restriction against loops,
so it might not be very clean.
There is an experimental 'category browser' mode which does some
limited sub-category display, but I'm not too familiar with it.
> 2) I would like to make a page that lists all entries organized by
> category, and paginated. So much like special:categories but with
> actual article listings in it.
Special:Categories just grabs the category names from the category
membership list in categorylinks, and throws away the page titles.
You'd want to do basically the same query, but without the DISTINCT and
pulling the titles out of a join to cur.
The QueryPage class might be too limited to support this paged output
cleanly, I'm not sure.
-- brion vibber (brion @ pobox.com)
More information about the MediaWiki-l
mailing list