4

I would like to use a category page as a template to show the "Pages in category..." on another page, but when I attempt to template the category page it only shows the details written on the category page itself. Not the list of pages in the category.

Is there any way to access this "Pages in category..." section outside of the category page itself?

For example, on a DnD wiki there is a category of type of spell in a class. Each of the spell pages for Druids is created and each of those spell pages has the Druid_Spells category. Then, the Category:Druid_Spells page has a text and some details added onto it.

I'm attempting to make a separate Druid page that has details about the class, but I don't want to manually edit and maintain the list of Druid spells. I would like to be able to pass the list of druid spells from the category onto the Druid page and as druid spells are added or changed the category would handle updating the list for me.

However, when I add this to the Druid page:

= Druid Spells =
{{:Category:Druid_Spells}}

It is only passing the text of the Druid_Spells category page. It isn't showing the "Pages in category Druid_Spells..." and listing all of them alphabetically like the category page itself does.

I would prefer not having to use the Druid spells category page itself because I would like to tie other category pages into the main Druid page, like skills and abilities.

https://stackoverflow.com/questions/1050853/transclude-a-category-in-mediawiki is a similar question, but all of the answers are extensions. Is this possible without an extension?

https://stackoverflow.com/q/72522845 I also asked here, but the only feedback so far is to ask here at Webmasters, or have the question closed because it isn't programming. Appreciate any help!

1
  • If you mean without a third-party extension, then see Extension:CategoryTree, which comes with MediaWiki since 1.31. I think it might do what you're asking, with the right combination of options.
    – Kevin E
    Commented Oct 14, 2022 at 4:26

1 Answer 1

3

If you wanted a list of subpages without needing to install an extension, yes, you can do that with Special:PrefixIndex.

As for lists of pages in a category, I thought maybe Special:CategoryTree, but it doesn't seem to work the same way as Special:PrefixIndex does when you transclude it. Which is kinda weird, I guess.

Screenshot showing Special:CategoryTree vs Special:PrefixIndex transclusions

I guess you could do something kinda hacky with Special:PrefixIndex, if you rearranged all your articles about spells to be named something like "Spells - Druid."

Special:PrefixIndex seems like it also works fine with namespaces, if you wanted to create a "Spells:" namespace and put all the spells there, for example. Just supply any URL query string parameters with pipes instead of ampersands. For example, change

https://www.mediawiki.org/wiki/Special:PrefixIndex?prefix=&namespace=4

into

{{Special:PrefixIndex|prefix=|namespace=4}}

and you get a bulleted list of all pages in the "Project:" namespace. See here for how to add your own namespace (requires the ability to edit LocalSettings.php).

What did immediately come to mind was Extension:DynamicPageList, but I assume you have some good reason for not wanting to use an extension, so I know that's not helpful. :/


Edit: I didn't even realize—until later—that Special:CategoryTree comes from Extension:CategoryTree, which is included with MediaWiki since 1.31. It has both a <categorytree> tag syntax and a parser function, so it will probably do what you need.

2
  • Thanks for the help. Unfortunately the wiki is below 1.31 but I appreciate the information about the PrefixIndex. I was told its old enough that updates might not work. However, the namespace and Prefix looks like a great idea!
    – Mattamue
    Commented Oct 21, 2022 at 1:12
  • 1
    @Mattamue I can appreciate the apprehension about MediaWiki updates, especially if it's been extensively customized, or relies heavily on extensions that may no longer be supported with more recent versions. But if it's any consolation, you can update a MediaWiki instance, no matter how old it is, it will just require somebody's time and energy to do so. See the "How hard is it to upgrade?" section of the manual.
    – Kevin E
    Commented Oct 21, 2022 at 16:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.