Topic on Extension talk:CategoryTree

CategoryTree in SideBar with HideRoot set to true

1
108.35.111.68 (talkcontribs)

I changed the file "CategoryTreeFunctions.php" to the following:

if ( !$hideroot ) {
				$html .= $this->renderNode( $title, $depth, $wgCategoryTreeDynamicTag );
			} elseif ( $hideroot or !$wgCategoryTreeDynamicTag ) {
				$html .= $this->renderChildren( $title, $depth );
			} else {
				$uniq += 1;
				$load = 'ct-' . $uniq . '-' . mt_rand( 1, 100000 );

				$html .= Xml::openElement( 'script', array( 'type' => 'text/javascript', 'id' => $load ) );
				$html .= 'categoryTreeLoadChildren("' . Xml::escapeJsString( $title->getDBkey() ) . '", '
						. $this->getOptionsAsJsStructure( $depth )
						. ', document.getElementById("' . $load . '").parentNode);';
				$html .= Xml::closeElement( 'script' );
			}

I added "$hideroot or" part. Don't know if this will have unwanted side affects in regular pages, but it does fix the problem of the Categories not displaying when hideroot is set to false.

Reply to "CategoryTree in SideBar with HideRoot set to true"