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)