php - Get list of current page's categories in MediaWiki -


i'm trying display page's categories in mediawiki skin without resorting following default code:

<?php if ( $this->data['catlinks'] ) { $this->html( 'catlinks' ); } ?>       

which adds bunch of unnecessary html not want.

<div id='catlinks' class='catlinks'>     <div id="mw-normal-catlinks" class="mw-normal-catlinks">         <a href="/wiki/special:categories" title="special:categories">category</a>:          <ul><li><a href="/w/index.php?title=category:player_character&amp;action=edit&amp;redlink=1" class="new" title="category:player character (page not exist)">player character</a></li></ul>     </div> </div> 

ideally category names plain text or array, don't want extrapolate them html returned code above.

how can echo mediawiki page's categories plain text?


update:

i'm using code generate category breadcrumbs wiki. starting top-level category , working it's way down. (not tested excessively). please note hacky , better extension.

    // current page's title     $wiki_title = $this->data['skin']->gettitle();     // categories     $parenttree = $wiki_title->getparentcategorytree();      // skin object passed reference cause can not     // accessed under method subfunction drawcategorybrowser     $tempout = explode( "\n", $this->data['skin']->drawcategorybrowser( $parenttree ) );     // convert data usable array     $wiki_category_breadcrumbs = explode( "&gt;", $tempout[1]);      // returns every category url <li> tags wrapped around     foreach( $wiki_category_breadcrumbs $value ) {                    echo "<li>". $value ."</li>";     } 

the fact categories available html, 1 of weirder parts of mediawiki skinning. should still possible fetch them array, though. depending on in skin code (you don't tell $this refers to), these (untested) snippets should job:

from execute()-function:

$title = $this->data['skin']->gettitle(); $categories = $title->getparentcategories(); 

from initpage()-function:

$title = $this->gettitle(); $categories = $title->getparentcategories(); 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -