Extension talk:TreeAndMenu

How to open only certain folder by default?
Hi, is there any way to open only certain folders by default instead of all or nothing? Thanks (again) in advance. --71.184.105.187 03:18, 4 September 2007 (UTC)
 * Currently the only way to do that is to use multiple trees each with their own openlevels parameters. --Nad 03:25, 4 September 2007 (UTC)
 * Perfect. Thanks! --71.184.105.187 03:31, 4 September 2007 (UTC)

Can't hide toolbox and navigation
Hi, I followed the directions on adding CSS to hide the toolbox and navigation sections, but it hides the tree, too. This is at http://wiki.passwordmaker.org. If you view the HTML source of that page, you'll see MediaWiki renders &lt;div id="p-tb"&gt; around the NavTree, so hiding that div also hides the tree. How do I make the tree render outside that div, or is there another solution? Thanks in advance. --71.184.105.187 00:21, 4 September 2007 (UTC)
 * I had a look at the source of your page and it should be possible to hide the heading and bullets specifically while keeping the main portlet container visible. I've changed the notes at Extension:Tree_view to reflect this. Let me know if it works since our wiki's don't do the sidebar this way so I can't test it myself. --Nad 00:38, 4 September 2007 (UTC)
 * Very close. The only thing remaining is &lt;h5&gt;Toolbox&lt;/h5&gt;, which is between the p-tb div and the pBody div. Take a look at the source again to see what I mean. It's too bad IE6 doesn't understand descendant selectors otherwise we could write #p-tb > h5 {display: none;}. Any other ideas? --71.184.105.187 02:32, 4 September 2007 (UTC)
 * No it's my fault, there shouldn't be a dot before the h5 selector as that specifies an element with class="h5", it should be fixed with the dot removed --Nad 02:47, 4 September 2007 (UTC)
 * That's it! Thanks for such a great extension! --71.184.105.187 03:11, 4 September 2007 (UTC)

Constructing Toolbox Links
Ok, last problem (I think)... When I try to duplicate some of the links in the normal toolbox - specifically the 'What links here', 'Related changes' & 'Printable version' links - using the {PAGENAME} variable, they don't work right for pages that have spaces in their names... see http://wiki.passwordmaker.org/index.php/How_it_works - even though apparently Mediawiki automatically adds the underscores to the page name, the actual page name has spaces, not underscores, and apparently the {PAGENAME} variable doesn't capture them correctly - I'm guessing this is a MEdiawiki bug, not necessarily a Treeview bug, but any ideas on how to fix this (worst case, I can rename all of our pages to ones with explicit underscores, which may not be a bad idea anyway)...
 * You should use the FULLPAGENAMEE variable (notice double E on the end meaning "encoded"), the best wikitext to make the link would be:

[ What links here]
 * --Nad 13:02, 4 September 2007 (UTC)
 * Hmmm... the above didn't work, but this did:

[fullurl/Special:Whatlinkshere/ What links here]
 * I was careful to recreate yours precisely, so don't know why it didn't work... but as I said, the above works, so unless there is a good reason not to use it, I think we're good to go... thanks for the pointer to the FULLPAGENAME variable!
 * "fullurl" is a mediawiki parser function, the wikitext above should have been copied and pasted exactly as is including the word "fullurl". It's ok how you have it now, but using fullurl is better as it's independent of your wiki's installation location etc. --Nad 22:35, 4 September 2007 (UTC)

Doesn't work for me at all
I've added the include code to my LocalSettings.php file, and put the latest Treeview.php into my "wiki/extensions" directory, and it simply prints my code out verbatim, without even trying to produce the tree view, i.e.

I know it's finding the Treeview.php file correctly, though, because if the file is not present it complains a lot. Sorry, I have no idea about mediawiki extensions or how to debug them. I just followed the instructions as best I could and it just ignored my attempt at making a tree. 217.42.127.214 20:07, 28 August 2007 (UTC)
 * When the code gets printed like that it usually means you've missed out the php delimteres (&lt;? and ?&gt;) --Nad 20:22, 28 August 2007 (UTC)
 * Sorry, I don't understand. I have the <? ?> delimiters in my treeview.php file and my LocalSettings.php file, (except there it starts with "<?php").  I just copied the treeview.php exactly as it's given here in the wiki.  Do you mean that I have to include those delimiters within the wiki code as well? 158.125.1.113 16:07, 30 August 2007 (UTC)
 * No if you've copied the code exactly and have the delimiters it must be another problem. I think I misunderstood your problem - when you say it's "print out the code" I thought you mean the treeview's php code, but you're meaning the wikitext as shown above right? that's a different problem, what version of MediaWiki are you running? does the extension show up the the special:version page? --Nad 20:41, 30 August 2007 (UTC)

I am having the same problem... here is our wiki so you can see what it looks like - see the 'toolbox' and 'navigation' entries underneath the real 'toolbox'? I'm completely open to the possibility that I did something wrong, but I dbl-checked and can't find a syntax error or anything in the mods I made... any help appreciated!

Yes, we are also having the same problem with the code from 30-Aug-07. MediaWiki 1.10.0 and the extension DOES show up in the special:version page!


 * I can see what the problem for the site at the url shown above from html source of the page. The treeview image paths are not set to the url's of the uploaded images, it's best to use $wgUploadPath to set the image names (I've updated the documentation to use it). Also the required image "doc-icon" is missing, probably because it was missing from OrganicDesign:Category:Tree view images but has been added now. --Nad 21:50, 31 August 2007 (UTC)


 * A few people have had trouble in the past with setting up the images properly, so I've made a new version (3.6.1) which requires only the image titles with no preceding path information, and only those that are different than the defaults need to be defined. The documentation has been updated again to reflect these changes. --Nad 23:33, 31 August 2007 (UTC)


 * That did it, thanks! Looks like your renamed Spacer.gif to Blank.gif too? This confused me for a bit (no indents in the tree). --71.233.89.119 02:19, 1 September 2007 (UTC)


 * Yeah some people had trouble with spacer.png because IE doesn't render png transparency properly without the monobook JS hack, but blank.gif works fine. --Nad 02:50, 1 September 2007 (UTC)

Eerror messages
I've tried to install it on my wiki but i get a lot of errors when i make a tree-entry on a page. (the tree is properly displayed!) The error messages are similar to this:
 * Notice: Use of undefined constant wgUser - assumed 'wgUser' in /var/www/html/wikidelfia/extensions/Treeview3.php on line 59

In the localsettings I put : include_once('extensions/treeview3.php') and the $wgTreeViewImages = array( with the proper links to the images. What is going wrong? --BB70 11:28, 14 March 2007 (UTC)
 * I know what that is - that's a setting in your php.ini that doesn't allow the array indexes to have their quotes missing - just put quotes around all the arrays, or download again - I've change the code to not depend on that setting now (I think I got them all, here's the diff). --Nad 23:19, 14 March 2007 (UTC)
 * It helps a little.. but i still get errors like: Notice: Undefined index: doc in /var/www/html/wikidelfia/extensions/Treeview3.php on line 84 (same for line 79 till 83) and these two: Notice: Undefined index: openlevels in /var/www/html/wikidelfia/extensions/Treeview3.php on line 85 ; Notice: Undefined offset: 5 in /var/www/html/wikidelfia/extensions/Treeview3.php on line 93. And there is a pop-up box with the message [object error] --BB70 07:42, 16 March 2007 (UTC)
 * You have your settings set extrememly strictly for it not to allow reading uninitialised variables and indexes! Check if it works now, I've made it only read them if they exist. --Nad 09:43, 16 March 2007 (UTC)
 * This works! Thank you for the quick response... --BB70 12:02, 18 March 2007 (UTC)

Parameter openlevel
When I use the paramater openlevel=1 (I also tried id=1) the tree stays closed. I tried the example in the article-text with the same result. Is there something else in the configuration I must change to get this work? --BB70 09:11, 19 March 2007 (UTC)
 * I've found the solution... It's not openlevel but openlevels --BB70 09:52, 19 March 2007 (UTC)
 * Sorry about that - typo fixed --Nad 21:00, 19 March 2007 (UTC)

JavaScript not being included
I have the same problem between 3.1 and 3.5. Here is my testwiki from home computer: testwiki two_php_files_modifiedphp_files
 * Well it seems to be wroking perfectly except for not adding the javascript for some reason - that bottom line problem is as I suspected which is that you have made an item two levels deeper than the one before which isn't allowed. I've updated it to add the JS in a better way which may solve your problem. If not there's a hack you can add to your localsettings after the treeview include to force it to add the javascript - the only drawback is that it'll be added even if there's no tree on the page.
 * $wgTreeView->addJS($wgOut);
 * Hmm, if i add the line above in my localsettings.php, i got the follow error message:
 * Fatal error: Call to a member function addJS on a non-object in /var/www/mwiki/LocalSettings.php on line 144
 * Besides, i just create a simple tree with only one sub-layer but result isn't much differentsingle-layer-tree
 * Lastly, i found that if i `touch` localsettings.php, then problem go away. But if i went to other computer and the Javascript just not insert again. This even happen between different browser (eg.IE and firefox). Could it be due to any setting on wiki i mis-configured? or sth i omit on LAMP configuration?
 * You must have added the hack before the include of the tree to get that error --Nad 08:13, 28 March 2007 (UTC)
 * I tried to add the line just right before "?>" and before "include_once('/var/www/mwiki/extensions/treeview3.php');". But it doesn't give me any different result apart from the line where error occurred.
 * Sorry, my mistake - you'll need to put the hack at the end of the wfSetupTreeView function before it's closing curly brace --Nad 23:35, 28 March 2007 (UTC)
 * and also change it to $wgTreeView->addJS($GLOBALS['wgOut']); since its inside a function now.
 * Also, are you using the usual MonoBook skin? your problem sounds a lot like bug 3603 which was that the monobook skin wasn't adding the headscripts, that was resolved in 1.6. --Nad 00:07, 29 March 2007 (UTC)

I also had the same problem. I'm on MW 1.9.3, Treeview 3.52 (2007-03-27) - standard monobook skin (some modifications to css, but none to the php file). Treeviews worked fine in preview mode, but no js was added to page in article mode. Tested a very simple treeview to eliminate weirdness there. Your hack above - $wgTreeView->addJS($GLOBALS['wgOut']); - works. Would link to the wiki, but it's on an intranet only. Zarius 10:53, 16 April 2007 (UTC)

Treeview in Sidebar!?
Hi as I can see on http://www.wikifs.org i.e. there must be a possibility to use the Treeview instead of the original Sidebar from MediaWiki. May anybody like to give a clou how it works?! Thanks.
 * I just commented out all the sidebar stuff in /wiki/skins/MonoBook.php and replaced it with the following, which then uses the "Navigation" article as sidebar content. You'll also need the CURRENTUSER variable for some of the links in you sidebar tree. --Nad 20:49, 3 April 2007 (UTC)

global $wgUser,$wgTitle,$wgParser; if (is_object($wgParser)) $psr =& $wgParser; else $psr = new Parser; $opt = ParserOptions::newFromUser($wgUser); $nav = new Article(Title::newFromText('Navigation')); $out = $psr->parse($nav->fetchContent(0,false,false),$wgTitle,$opt,true,true); echo $out->getText; return true; }


 * Isn't there an easier way, like by using MediaWiki:Sidebar? I tried doing it but I don't think that field recognizes templates (or however Treeview is called). There needs to be a user-friendlier way of adding/editing the sidebar treeview menu than having to dork with PHP files... :/ -Eep² 22:08, 23 July 2007 (UTC)
 * No, for some reason they didn't make MediaWiki:Sidebar allow wikitext and there's no hooks allowing it to be extended. We use Extension:WikiSkin which allows the entire skin to be defined in wikitext. --Nad 22:51, 23 July 2007 (UTC)
 * I added a new hook to Monobook.php (just one line of code) right at the top of the nav bar and tied the navtree to that hook. And I used mediawiki:Common.css to hide the original navbar items with #p-navigation { display:none }. This works fine, see http://semeb.com/dpldemo. Algorithmix 07:02, 16 August 2007 (UTC)

I've got the Problem that the tree does not open at anytime? sometimes it works and sometimes not, is there anybody with a helping hand or the same problem?
 * It sounds similar to the problem above under the "JavaScript not being included" heading. Otherwise, give me the url of your wiki and I can have a quick look --Nad 10:01, 11 April 2007 (UTC)
 * I can't come out I am sitting behind a firewall. :( What kind of problem might it be? Setting the var. $wgAllowUserJs = true; does not change a lot.:(
 * Have you tried the hack recommended above? is you tree in normal page or in sidebar? --Nad 21:07, 11 April 2007 (UTC)
 * Oh yeah my mistake. Think I have to learn reading again ;) Thank you for you fast answeres!! Now it works.

Subtree functionality
I'm having problems getting the subtree functionality working. I took your example and Tree1 does not show Tree2 as a folder that I can click to open. It just shows as a DOC icon. Here is my code:

Roger R Cruz 22:18, 14 May 2007 (UTC)

Treeview can't be invoked from a template
I have the following template: Test

when I try to invoke it in another page via

I get the following error: O@@@ Tree1 Item1 Item2 C@@@ Roger R Cruz 22:40, 14 May 2007 (UTC)
 * That's a current bug which I'll fix when I've got some time to work on it next, but there's a temporary solution, for example to transclude your "Test" tree article, do the following:

Empty Folder
I have the need to create just the top level bullet list (folder) that does not have any sub-entries below it. However, if I don't at least include a list subentry (** subitem 1), I don't get a folder to show for the tree. It shows as a DOC. --Roger R Cruz 22:52, 14 May 2007 (UTC)
 * All nodes having no child nodes show as a doc (leaf node), you'd have to change $wgTreeViewImages['doc'] to your folder icon if you want them all to be folders regardless of whether or not there's any child nodes. --Nad 23:31, 14 May 2007 (UTC)

Missing JavaScript and missing parser tags
I'm having problem similar to the other non-included JavaScript issue on my two wikis (running 1.10), but the head JS is included, and the Body JS isn't, so none of the folder icons are clickable (to expand the tree!) I would link to the wikis but they're on my computer and on an intranet... I will provide any troubleshooting information needed upon request.

Thanks! Rockerbaby 19:15, 7 June 2007 (UTC)
 * I have the current version running properly on 1.6.10, 1.9.3 and 1.10.0, so it's not a mediawiki version problem, if either of your wiki's are publically accessible I could have a look and see if I can see what the problem is... --Nad 22:53, 8 June 2007 (UTC)


 * I will set up a blank test wiki (running 1.6.9 due to the fact that my host only supports PHP4) and install the extension there. I cannot open the 1.10 wikis to the public due to ISP restrictions on servers, but if it helps I can copy the produced HTML code and the LocalSettings.php files to my userspace here. What happens is the A HREF tags in the body aren't being copied into the rendered content. I removed all other parser hook extensions to check for compatibility, and it still didn't work. Thank you for your help! Rockerbaby 04:52, 9 June 2007 (UTC)


 * Actually All fixed. Turns out I had the file extensions wrong on plus and minus in the configuration, so the links weren't even showing up. Oops! Rockerbaby 05:24, 9 June 2007 (UTC)

Tree View Doesn't Display at all
I have installed the extension and the pictures, added it all to the localsettings. When I try the syntax all I get is Root displaying. Only Root shows. Any ideas? Please e-mail me @ mike.madeja@gmail.com, Thanks
 * I have the exact same problem. Manu3d
 * This problem has been solved, it was due to wrong image paths. Check the html source of the page containing the problematic tree in your browser, and ensure that the image paths it's using are correct. --Nad 21:00, 27 June 2007 (UTC)

Tree View in Sidebar : advanced

 * I integrated Tree View in the side bar and its working so far (ehm so great)
 * I don't like to miss "Seek" and "Toolbox", anythig else is missing using personal css, (and will show up again for other users)
 * but I'ld like to see Tree View on top, just below the logo and before the seek-option

I can't figure out to change from "MonoBookTemplateToolboxEnd" to the beginning of this array (while the automatic changing of the Toolbox-content should be still working)

Any Idea? - Thank you!
 * If you're wanting more control over the sidebar content, then you'll need to hack the /skins/MonoBook.php file. The way I do it is to replace the part of the file which renders the toolbox with the following code which allows the MediaWiki:Sidebar article to contain normal wikitext such as a treeview:


 * I asked for "Any Idea", and you are right presenting this one. But I have to face that this informtaion is to heavy for me.
 * I did a workaround within monobook.php:


 * 1.) Killing line
 * which I found in the end of div
 * which I found in the end of div


 * 2.) including
 * which I placed just behind the closing div of
 * seems to work so far
 * seems to work so far
 * seems to work so far

Collapseable tables
Hello, I am seeing a error when I place a treeview inside a template page, and then refer to that template in a [collapsible] table. Once I click on show, it expands all of the nodes at once, but still shows the root nodes as unexpanded. Is there any way to make the treeview resume the default setup and not expand every node? --Jgetzke 15:50, 17 August 2007 (UTC)
 * Can you give me a link to the site this is happening on or is it intranet? --Nad 22:37, 19 August 2007 (UTC)
 * Unfortunetly it is on intranet. If you want, I would be happy to duplicate the error on your wiki.  You would need to install the Navframe/collapseable function from Wikipedia first.  Below is what the code looks like on our wiki:  --Jgetzke 16:12, 20 August 2007 (UTC)


 * style="border: 3px solid #E41F1F; align: left; color: #42617B; height:210px; font-size:11px; width:300px;" valign="top" |


 * Sorry for the slow response, I've been away and have a lot of work to catch up on. If you like you can set up the problem on www.wikifs.org, which is one of our test wiki's, I can make you a sysop on it so you can access the css and js articles. --Nad 23:22, 24 August 2007 (UTC)

Sidebar Tree Issues
I'd like to be able to replace the navigation box at the top of my sidebar with http://daniel.cook.name/index.php?title=FamilyTree but the I'm not sure what to replace in monobook.php. I read your comments above (from April 3rd)"I just commented out all the sidebar stuff in /wiki/skins/MonoBook.php and replaced it with the following" I cannot figure out what stuff to comment out...  Can you please be a little more descriptive?

...Also, how do you get your sidebar to dynamically resize at http://www.organicdesign.co.nz/? Thanks in advance.
 * Not sure what you mean by this, my sidebar always stays the same size...? --Nad 23:52, 24 August 2007 (UTC)
 * Click on Site Map - The Nodal Model. Watch your sidebar grow to the right to accommodate the text.
 * I see, it probably happens by itself because we use a table for our layout (using Extension:WikiSkin to define the skin in an article instead of a file). It can probably be done with css too, but the guy who does most of our css (OrganicDesign:User:Rob) is on holiday for a couple of weeks and I'm not all that good at it. --Nad 02:31, 25 August 2007 (UTC)

Okay, thanks. I'll take a look at WikiSkin. Regarding the first question. Can you please tell me what I should delete and exactly where I should drop this code in to Monobook.php?

global $wgUser,$wgTitle,$wgParser; if (is_object($wgParser)) $psr =& $wgParser; else $psr = new Parser; $opt = ParserOptions::newFromUser($wgUser); $nav = new Article(Title::newFromText('Navigation')); $out = $psr->parse($nav->fetchContent(0,false,false),$wgTitle,$opt,true,true); echo $out->getText; return true; }

I've created a copy of my FamilyTree article and called it Navigation. I'd like to lose the default navigation and toolbox and replace them with mine. I appreciate the help!
 * I've added a modified version of Monobook.php at Replacing sidebar content which has the search, toolbox and language links commented out, and the code added to render the navigation article in their place. --Nad 04:03, 25 August 2007 (UTC)
 * You ROCK, Nad. Thank you.  [EDIT] Hmmm.  I get

Parse error: syntax error, unexpected ';', expecting T_FUNCTION in /home/listcoo6/public_html/daniel/skins/MonoBook.php on line 266 Ideas?
 * Oops didn't have the php delimiters quite right - probably best just to remove those commented out bits you don't want anyway (make a backup of the file first tho). And may be best not to use the version on OD just in case the version isn't the same as yours - that example was from a MW 1.10.0. --Nad 04:23, 25 August 2007 (UTC)
 * You may want to also install Extension:Semantic MediaWiki at some stage too which allows relationships between the people to be defined for better reporting etc. I'm working on a gedcom importer for mediawiki too, but have had too much work on recently to make much headway with it but the format doesn't look too difficult. --Nad 04:38, 25 August 2007 (UTC)

Excellent lead on Extension:Semantic MediaWiki. Thanks for everything.

Nodes instantly collapse after expansion
Hello! - I'm having two problems that I can't figure out...
 * When I expand a node, as soon as I click on an item in the list, the node collapses again - very frustrating - and,
 * That's a strange problem?! can you give me a link to the wiki in question? if not supply html-source code of page having the trouble, and let me know info from special:version page. --Nad 06:48, 1 September 2007 (UTC)
 * http://wiki.passwordmaker.org... I'm working with Eric on getting Treeview working properly, and he already got your help with hiding the normal toolbox and navigation trees (thanks!) - The bottom unexpanded 'toolbox' and 'special' trees exhibit the problem...


 * Is there a way to make some of the nodes expanded by default?
 * Add openlevels=some-number to your tree definition. I've added an example in the usage section. --Nad 06:48, 1 September 2007 (UTC)

Thanks for any help! - charles