Topic on Extension talk:CategoryTree

Output a category tree anywhere in the skin

2
Sophivorus (talkcontribs)

Hi all! I'm designing a skin, and I want to include a category tree in the footer. I'm trying to figure out the code necessary to output it, by I've been failing for hours. The problem is always the same: the tag gets parsed, but the ext.CategoryTree.js is not loaded, so the JavaScript is never run and the tree doesn't work. Below are some of my attempts, but none worked. They were all within the skin template class, which extends BaseTemplate. Thanks!

echo efCategoryTreeParserHook( 'Some category', array( 'mode' => 'all' ) );
$parser = new Parser();
echo efCategoryTreeParserHook( 'Some category', array( 'mode' => 'all' ), $parser );
$title = $this->getTitle();
$parser = new Parser();
$parserOptions = new ParserOptions();
$parserOutput = $parser->parse( '<CategoryTree mode=all>Some category</CategoryTree>', $title, $parserOptions );
echo $parserOutput->getText();
93.212.68.54 (talkcontribs)

I'm trying to do the same thing as Luis, unfortunately, with the same results. Actually, showing a tree in the regular sidebar would be good enough for me, but setting SidebarRoot and ForceHeaders has no visible effect, nor does adding "** categorytree-portlet" to MediaWiki:Sidebar.

Invoking the parser explicitly from the skin, using the third method above, produces a non-interactive tree, matching the description under no effect/error/sits on loading.

Any ideas? A quick hack would suffice ... Some more info below, but it's perhaps not that helpful -- I'm not a web developer, and still don't know much about MW. My version is 1.24 by the way. Cheers, David

Update: The solution that Bhuber outlined here is the quick fix I was hoping for. That in combination with the explicit call to Parser::parse.

Inside an article, the tree works flawlessly. When inspecting the source code of the generated webpage, I see no difference between the (working) tree inside the article and the tree in the sidebar. The showToggles() JavaScript function is even called in both cases; that function is supposed to make the expand/collapse arrows visible. However, after calling "css('display', 'inline')", the value of 'display' remains 'undefined' in the case of the sidebar tree. If I make the arrows visible by setting $linkattr['style'] = 'display: inline;' in CategoryTreeFunctions.php, clicking them has no effect; handleNode isn't called.

My custom skin is not derived from Monobook or Vector; switching to either of those makes no visible difference though.

Reply to "Output a category tree anywhere in the skin"