Extension talk:CategoryTree

Jump to navigation Jump to search

About this board


1 (2006/2007) - 2 (2008) - 3 (2009) - 4 (2010) - 5 (2011)

How to define the tree node? ( Rookie stupid problem )

Alexandroslee (talkcontribs)


I don't know how to define the tree node?

I had install Extension:CategoryTree https://www.mediawiki.org/wiki/Extension:CategoryTree

and had activated

but I don's know how to define the tree node ?

such as

<categorytree mode="pages">abc</categorytree>

<categorytree mode="pages">def</categorytree>

means I would create a page abc this a tree node

and I

<categorytree mode="categories">xyz</categorytree> this is parent node?

<categorytree mode="pages">abc</categorytree>

<categorytree mode="pages">def</categorytree>

Please help me

this is a Rookie stupid problem

-- Alexandroslee (talk) 07:41, 14 August 2018 (UTC)

Alexandroslee (talkcontribs)

copy the code and I creat a category Manual

<categorytree mode="Category" style="float:right; clear:right; margin-left:1ex; border:1px solid gray; padding:0.7ex; background-color:white;">Manual</categorytree>

but won't work?!

Alexandroslee (talkcontribs)

I had create a Category:Manual

the content like this



Tacsipacsi (talkcontribs)

Could you please share more details? What does “not working” mean? There is no output? You get some error message? The raw wikitext is displayed? Something else? Have you verified that the extension is installed (i.e. it shows up on Special:Version)? Can you share an exact URL where the problem occurs (if the wiki is public)?

Alexandroslee (talkcontribs)

I am useing version 1.26.3

I had successfully use to show the tree,

But how could I use the "custom tag " ?

Alexandroslee (talkcontribs)

Would you mind providing some examples for

The {{#categorytree}} parser function and

The Special:CategoryTree page for me?

I try to control the sequence of the tree items

Alexandroslee (talkcontribs)

and I can't hide the prefix

<categorytree mode="all" hideprefix="always">Job:jobcategory</categorytree>

but won't work !

please help!

Alexandroslee (talkcontribs)

now I use the wiki category , and I try the namespace ( such as "Job:FEE" )

and I wish I could hide the Job (prefix ? ) only left "FEE"

how should I do?

Alexandroslee (talkcontribs)

I am useing zh-tw and the syntax seem change to traditional Chinese

it make me very Confuse

suck as the category been to "分類" so I have to add the category like 分類:jobcategory

but when I try to create the namespace like "jobs" and the category like 分類:jobs:jobcategory

and when I setup the category tree like

<categorytree mode="all" hideprefix="always">Job:jobcategory</categorytree>

but the prefix "jobs" still show at each item !

I am frustrated , please help, Tanks a lot!

Alexandroslee (talkcontribs)

I try the Category:Manual

and the sub is Manual:Contents

that meas the namespace is a Category

so I have to set a Category such as "jobs"

then I create jobs:FEE and jobs:BED and jobs:FED

the put the

in each page jobs:FEE and jobs:BED and jobs:FED

then how can I use the category tree and hide the prefix "jobs"

that is my question

Alexandroslee (talkcontribs)

I use the mode="all' and expected the pages is show off

but only categoris show !

what's worng I made?

Alexandroslee (talkcontribs)

so I would like to know

how to

as a "custom tag" (or "parser function") to show a category structure in-line on a wiki page,


and as a special page.

Is there some examples ?

Tacsipacsi (talkcontribs)

Your messages are a bit messy for me, I answer what I understand:

  • Items are ordered by type (category, page, file, in this order), and by sort key within each type. This behavior cannot be changed, but the sort keys can be, of course.
  • hideprefix hides namespace prefix. For Category:Jobs:Jobcategory it’s Category:. For Jobs:Jobcategory it may be Jobs: if it’s a real namespace registered in MediaWiki, or nothing otherwise. Pages can’t have more than one namespace, so a category’s namespace will always be Category.
  • mode=all should show all pages in the category, i.e. the ones that show up in the category listing (not the ones that are manually linked from the category page). If it’s not the case, you’ve found a bug.
  • <categorytree> is a custom tag which shows a category structure on a wiki page, and Special:CategoryTree is a special page. Why aren’t they good?
Alexandroslee (talkcontribs)

Thank you very much ! I had show the category tree now, but only the order

how about the " sort keys " you mention ?

Alexandroslee (talkcontribs)

Thanks , now I got the meaning of Special:CategoryTree is a special page,

cause I think maybe I could edit the special page to defind the items and order

Tacsipacsi (talkcontribs)
Reply to "How to define the tree node? ( Rookie stupid problem )"

Is there a "folder icon" alternative format for CategoryTree

GregRundlett (talkcontribs)

I'd like to use "folder" icons for categories, and mime-type "page" icons to mimic a file browser instead of the small triangles of CategoryTree. Does such an option exist, or does anyone know of an implementation that does so? Something like this jQuery plugin (talkcontribs)
Reply to "Is there a "folder icon" alternative format for CategoryTree"

Split a long list into Multi-Column Lists

Samuel Goujon (talkcontribs)

Hi all,

Would it be possible to split a long list into multiple horizontal columns?

For example, every 50 categories, a new list is created on the right (keeping the alphabetical order)

Thanks for your help!

Cmjohannes (talkcontribs)

I would also like to know if this functionality is possible. I have a category with 300 member pages, which I would like to display on my main page. Currently, the CategoryTree extension displays one page per line. I would like to use a four or five column table to improve site aesthetics and make the list more readable.

Something like:


<tr><td>Page A</td><td>Page B</td><td>Page C</td><td>Page D</td></tr>

<tr><td>Page E</td><td>Page F</td><td>Page G</td><td>Page H</td></tr>


Where/how could/should such display output be implemented? (talkcontribs)

Use template:columns from wikipedia. Just put the categorytree inside the template:columns.

Reply to "Split a long list into Multi-Column Lists"

Download list of subcategories without explicit implementation?

1 (talkcontribs)

Hi, I apologise if this may sound silly but I have just come across this category tree which seems very handy but I need just lists of categories and subcategories (like an xml/ json file) as opposed to a visual API of the tree. I realise I could use this API and gradually construct my own list but would ideally like to not have to spend time implementing this if there is a faster route.

I have also come across pywikibot which is suggested below for downloading pages with specific categories, but I am needing to download a lot of pages that fall under the categories "science" and "technology" so a bot is not the best option (I am currently working with the wikidump data: enwiki-20170820-pages-meta-current.xml.bz2 (25.86gb))

Reply to "Download list of subcategories without explicit implementation?"

New Instructions are Confusing and Unclear

Johnywhy (talkcontribs)

this instruction is incomplete and confusing:

"if [when??], then mode=pages will be used. It means that if the site configuration hasn't been changed [changed in what way?], the following are equivalent (site configuration may affect the third one)"

Extension:CategoryTree#Notes on the 'namespaces' parameter

Previously, the notes said "otherwise... otherwise... otherwise". Three "otherwise" in sequence is confusing. I attempted to improve with bullets. Meaning is still unclear.

Tacsipacsi (talkcontribs)

I found only one otherwise, which means, as always in English, “if none of the above are true”. Of course it’s incomplete if you change it to “if [when??]”. I tried to clarify the site configuration change.

Johnywhy (talkcontribs)


Reply to "New Instructions are Confusing and Unclear"
Johnywhy (talkcontribs)

the tree still shows deleted pages.

Johnywhy (talkcontribs)

Tree shows old version of renamed page.

Any fix?


Reply to "How to force refresh?"

force categorytree to update when add new page.

Summary by Sarise298
Siggiae (talkcontribs)

I am invoking categorytree with the syntax {{#categorytree:Embryo|mode=pages|showcount|depth=2 etc. When I create a new page and add it to the category Embryo, categorytree will not list the new page. I can close/open the page that invoked categorytree, login again with no effect. If I look directly at the page Category:Embryo the new member page is listed immediately. The only way I can get the {{#categorytree:Embryo etc to update is to resave the page where it occurs. Same behavior if I use the tag syntax.

There must be a better way, I thought this function was dynamic. No obvious warnings of this behavior on the relevant help page or in discussions. Suggestions? (talkcontribs)

I'm also seeing this. shouldn't it populate the tree automaticly? (talkcontribs)

yes it should make the tree grow even tho right not my tree isnt growing

SmartK (talkcontribs)

We would also like to know if there is a "fix" for this. I have noticed that updates of pages and categories are shown in categorytree with a long time difference. Maybe we have to run some kind of job to update the database in the background? I can reproduce this with mediawiki 1.27.0. (talkcontribs)

I confirm the issue too. MW 1.27.1

Dturtill (talkcontribs)
Dturtill (talkcontribs)

There is a possible temp fix for this if you disable Caching for your wiki then they change instantly to do this add the following at the bottom of your LocalSettings.php file.

$wgEnableParserCache = false; $wgCachePages = false;

Johnywhy (talkcontribs)

thx for that, could be useful for other things!

but, doesn't seem to fix CategoryTree...

This post was hidden by FDMS4 (history)
Reply to "force categorytree to update when add new page."
Johnywhy (talkcontribs)
Ciencia Al Poder (talkcontribs)
Reply to "How does ifeq work?"

How to Restrict CategoryTree to a Particular Namespace?

Summary by Johnywhy

"Category" is a namespace. So, when you use the namespaces parameter, you must include Category in namespaces, if you want subcategories to show up in the result.


{{#categorytree:TOC|hideroot|namespaces=Main Category}}

If you don't include the namespaces parameter, then "namespaces=Category" is implied.

The "mode" parameter is disabled by the "namespaces" parameter, but you can achieve categories mode by leaving namespaces blank. Subcategories will appear, but not pages:


hideroot works as expected.


Notes added to the Extension documentation:

Extension:CategoryTree#Notes on the 'namespaces' parameter


Extension:CategoryTree#When i use the namespaces parameter, i don't get any pages

Johnywhy (talkcontribs)

Re gunretort.xyz

Doc says:

a list of namespaces from which pages should be shown in the tree (since rev:36864, July 2008). The entries in the list must be namespace names, separated by spaces. The main namespaces can be represented by "-" or "0". This overrides the mode option. 

But, none of these work-- i get an empty tree

Tacsipacsi (talkcontribs)

Of course you get an empty tree, as Category:TOC is empty. I works for me with an existing category.

Johnywhy (talkcontribs)

TOC isn't empty

Tacsipacsi (talkcontribs)

Just click on the red link above. It’s completely empty. (If you use another wiki, where it’s not, you should mention it. This extension works perfectly on this wiki.)

Johnywhy (talkcontribs)

For gunretort.xyz

Note, TOC tree works fine on my site, gunretort.xyz: returns all categories and pages. This works, no prob:


The problem is `namespaces=Main` doesn't work. None of these work:.








Tacsipacsi (talkcontribs)

The first one (namespaces=Main) works for me using the API (I haven’t tested the other ones). I used the API because I can’t test using the normal edit interface, as anonymous users cannot edit pages. (Please note that some security software may warn for possible XSS (cross-site scripting) attack for the above URL. It’s because of the curly brackets in the wikicode, and the page is absolutely safe to visit.)

Johnywhy (talkcontribs)

Thx for testing. I see your url is:


It brings up a page of raw json. I notice that it only contains the word "Welcome". It doesn't show any of my subcategories or pages.

I tried your syntax on a wikipage


Again, the result is just the word "Welcome", which is the only page in the top-level TOC category. It does not have an assigned namespace: https://gunretort.xyz/index.php/Welcome

Other pages are in sub-categories of TOC, with no assigned namespace. They don't appear in the tree. Shouldn't they?

This syntax shows all sub-categories, all pages:


Clue: Extension doc says "namespaces" parameter: >"This overrides the mode option." It's unclear what "override" means. But it seems it actually disables subcategories.

I performed another test: i created a page in the TOC category, and the "Published" namespace. I also moved a different page to Published namespace, in a subcategory. We get only the page in the top-level TOC category, Published namespace. More evidence that 'namespaces' parameter ignores subcategories.

Tacsipacsi (talkcontribs)
Johnywhy (talkcontribs)
Johnywhy (talkcontribs)

Doc says

> "to drop your own wikitext article into the Sidebar, and then add CategoryTree items to it...."

  • What does that mean? What "article"? i thought we're talking about a tree. Do they mean a link to an article?
  • What does "add items" mean? I thought the point of the tree is that all items are automatically added.

> If you want the CategoryTree on a different position in the sidebar, you can reference it on MediaWiki::Sidebar as "categorytree-portlet"

  • tried that. It just gave me a link to a non-existent page called "Categories".

> To append a link "CategoryTree" to your toolbox (sidebar) add following code to the javascript-page...

  • Huh? All that javascript just for a link to category tree? But i want the whole tree.

> Add these lines to LocalSettings.php:

  1. > $wgCategoryTreeSidebarRoot = 'Category:article_name';
  2. > $wgCategoryTreeForceHeaders = true;
  • Again-- unclear. What's the point of a tree, if we're only putting one article in the sidebar?
  • Where are the parameters in above instructions? If i've worked out a set of parameters that gives me the exact tree i want, how do i apply those parameters to a tree in the sidebar?
Reply to "Problems Adding Tree to Sidebar"