问题
I'm not quite sure if this is possible in MediaWiki.
I've got several categories, each containing a few pages. If you open a category page you'll see the contents of the category that usualy consists of these three parts:
- A user defined text (which can be edited by using the edit link).
- All subcategories that are attached to this category.
- All pages that are attached to this category.
My goal is to create a page that includes at least part #3 of several categories. A page that shows me all page names that are attached to multiple categories of my choosing, grouped by their category.
My first approach was to use the standard transclude syntax of MediaWiki:
Category A contains these pages: {{:Category:A}} Category B contains these pages: {{:Category:B}} Category C contains these pages: {{:Category:C}} ...
Unfortunatly, this only transcluded part #1 of a category: the user defined text. The page name listing was missing.
My second idea was to have a look at the parser functions. Perhaps there are some functions that offer enumerating through the pages of a category. But I didn't find any.
Perhaps there is a MediaWiki extension out there...
Is there a clever way to realize this?
回答1:
Try http://www.mediawiki.org/wiki/Extension:CategoryTree, with the following syntax:
Category A contains these pages:
<categorytree hideroot="true" namespaces="-">Category A</categorytree>
回答2:
If you want more control over how the results are displayed, you may want to give Semantic Mediawiki a try.
The syntax would look something like:
Pages in Category A:
{{#ask:[[Category:A]]
|format=ul
}}
Even if you are not using semantic properties, you can use the query mechanism to display pages based on categories.
回答3:
The MediaWiki extension Dynamic Page List (http://www.mediawiki.org/wiki/Extension:DynamicPageList_(third-party)) does this with ease, producing bulleted lists of articles in a category:
Pages in Category A:
<dpl>
category=A
</dpl>
without a heavyweight solution like Semantic MediaWiki. Just install and go.
DPL has a rich syntax for more powerful dynamic lists. For example, to produce a numbered list in 3 columns:
<dpl>
category=A
mode=ordered
columns=3
</dpl>
来源:https://stackoverflow.com/questions/1050853/transclude-a-category-in-mediawiki