Extension talk:TreeAndMenu

Problems on links in tree
Hi there, I like your TreeView. But there are some Problems for me... - when I add just text everything is fine. When I add links   in preview everything is still fine. But when I save the #tree closes right before the first link. Example:

SectionA  Of course when the brackets are closed the following stuff is not included. Anyone knows how to repair this? btw: I use MW 1.11.0, FireFox, MacOS, MAMP Ben
 * Sorry I haven't come across that problem before, is it the latest treeview version? --Nad 07:02, 28 January 2008 (UTC)

version 4.0.9
--Tepo 21:18, 20 January 2008 (UTC)

I've installed Treeview4, version 4.0.9 on a MW 1.6.10. The code is properly included, the image paths (in the source of the article page) refer to the right locations (the gif files are all there where the paths refer to) and the JS script is included in the source page as expected. But the tree is rendered literally as if it was a standard wiki article and as if the magic word was never acted upon. The icons do not show up; the treeview table is not being defined. From tracing the Treeview4 source code, my impression is that neither function Tree nor function treeview are invoked. It looks as if nothing happens after function Treeview4 has executed. Any suggestions how to resolve this?
 * The # symbol is not implied in some older versions of mediawiki, so you may need to either remove the # from the wikitext, or set $wgTreeView4Magic to "#tree" instead of just "tree" --Nad 06:54, 28 January 2008 (UTC)
 * Solved! Thanks a lot! --Tepo 20:42, 1 February 2008 (UTC)

Treeview not displayed

 * 1) i create file Treeview4.php
 * 2) insert code in localsettings
 * 3) but, if i insert in Mediawiki:sidebar, menu not displayed. in Mediawiki:sidebar i insert example from docs.
 * If you want the tree to work in sidebar, you have to add the skin hack to allow the sidebar article to render wikitext, see Sidebar for more detail about that. --Nad 06:48, 28 January 2008 (UTC)

Treeview suddenly stopped working in Navbar
Hello... we have a very strange problem... there have been no changes to the MediaWiki version or Treeview version, but all of a sudden, insted of the Navbar displaying normally, it is full of lines like this:

UNIQ136a4e0848c93b3c-TreeViewRowStart-00000001-QINUsite�UNIQ136a4e0848c93b3c-TreeViewRowEnd-00000002-QINU �UNIQ136a4e0848c93b3c-TreeViewRowStart-00000003-QINUIntroduction�UNIQ136a4e0848c93b3c-TreeViewRowEnd-00000004-QINU �UNIQ136a4e0848c93b3c-TreeViewRowStart-00000005-QINUHow it works�UNIQ136a4e0848c93b3c-TreeViewRowEnd-00000006-QINU �UNIQ136a4e0848c93b3c-TreeViewRowStart-00000007-QINUScreenshots�UNIQ136a4e0848c93b3c-TreeViewRowEnd-00000008-QINU

See it live here:

http://passwordmaker.org

This is on a shared hosting server (asmallorange) - anyone have a clue what might be causing this?
 * I have no idea why that would suddenly change if no changes were made to any of the code or extensions. I'd recommend upgrading to the latest version as treeview 4 is more reliable code than 3.x. --Nad 06:45, 28 January 2008 (UTC)
 * Never mind - figured it out... !@#$#$^%^ hosting company enabled zend.ze1_compatibility_mode... sorry for the noise.

White block with width 100%
Help please, i integrate treeview in sidebar and edit monobook.css, but all the same i see a white block with width 100%. In ie6 this block down on content.

look:

How delete white block, all resize to necessary size?

PS: I try with width=100% in css - no result.
 * It must be a css problem, try installing firebug into firefox and then right-click and "inspect element" to see what css rules your tree container has had applied to it --Nad 07:27, 8 February 2008 (UTC)

Monobook.css How-to?
Ok, I'm a dummie... so how do I add the Monobook.css stylesheet to our MediaWiki as described so I can change the font size back down to a more reasonable size... which begs the question, why is it so much bigger when going from 3.6 to 4.0.9?

Thanks --
 * Just navigate to your Article MediaWiki:Common.css and there you can change yout css code. Ben --212.184.19.70 07:11, 19 February 2008 (UTC)

MW 1.12+
Any chance this thing is going to work on MW 1.12, PHP 5? Tim Laqua talk 19:55, 28 February 2008 (UTC)
 * Treeview5.x will be made to work with 1.12, we don't have a 1.12 set up to test on yet, what's it doing wrong? --Nad 19:58, 28 February 2008 (UTC)
 * It's all crazy, here's the HTML that results from the parser function example on Organic Design:

&lt;treeview547c711fe2c3f3 id='47c711fe2c3f3' openlevels=4 root='My example tree'&gt;*Node 1 Node 1.1 Node 1.1.1 Node 1.1.1.1    Node 2 </li>Node 3 </li>Node 4 </li>My Pictures The trip to Iceland </li>Mom's birthday </li></ul> </li>Recycle bin&lt;/treeview547c711fe2c3f3&gt; </li></ul> I've got a 1.12 install set up to work with now and have worked out a solution which should get it working on 1.12, it should be ready within the next few days --Nad 10:20, 29 February 2008 (UTC)
 * Can I get a quick hack (or some direction) to get it working in the mean time? Tim Laqua talk 13:19, 29 February 2008 (UTC)
 * As soon as I get it working I'll update the code. The parser has undergone massive changes in 1.12 and I've had to work out a different way to do the main parser function. --Nad 02:20, 1 March 2008 (UTC)
 * 5.1.0 is ready and tested fine on 1.11 and 1.12, it's almost a complete rewrite, so there may be some new problems crop up --Nad 21:10, 2 March 2008 (UTC)

Use cookies?

 * Has anybody added cookie functionality to this extension yet? It would be great if opened/closed trees remained that way from page to page. SeanFromIT 18:36, 2 October 2007 (UTC)
 * I'm back on tree now and working on custom images and persistence --Nad 00:58, 3 October 2007 (UTC)
 * Persistence is now available via cookies in version 5.x.x --Zven 23:01, 10 March 2008 (UTC)

Suggestion - add thumbnailing of images
I use the following (from line 63 of Treeview5.php) to transform down to 18px: $image = Image::newFromTitle($title); if ($image && $image->exists) { $thumb = $image->transform( array( 'width' => 18 ) ); $v = $thumb->getUrl; } else { $wgTreeViewImages[$k]; } Tim Laqua talk 21:46, 3 March 2008 (UTC)

Where to put tree list?
The plugin looks great and I'm anxious to use it. However, the latest documentation appears to be missing something:

>>Usage

>>Tree-views are created by surrounding a normal nested bullet list within the following couple of examples:

That's great, but with all of the supporting files for MediaWiki, which one of the hundreds of files do I put this in? I'm assuming it goes in Monobook.php, but I'm not sure. I've tried putting it in both Monobook.php and LocalSettings.php, both of which give me a parse error when it hits the first bullet:

Parse error: syntax error, unexpected '*'

What am I missing here?

Thanks, Scott
 * I'm not quite sure what you mean? are you asking where you put the bullet list? it's wikitext and you put it in the article where you want the tree to be... or are you referring specifically to how to put a tree in the sidebar? if so see Sidebar... otherwise please explain what you're trying to do and what the problem is more clearly. --Nad 04:35, 4 March 2008 (UTC)

Nad - Thanks, you answered my question. I wanted the tree view to be in the Wiki Side Bar, as well as a nav tree once I get to a particular page. I'll take a look at the side bar info and see if I can make the appropriate change(s).

Strange Error
I am getting a javascript error and I am not sure what it means of how to fix it.

invalid flag after regular expression for (i in tree.icon) tree.icon[i] = '/wdev_wiki/extensions/TreeView/'+tree.icon[i];/data/www/mediawiki/extensions/TreeV... ---^

Any ideas? Thanks, Pete.

I figured this out! At line 166 in 'TREEVIEW5_VERSION','5.1.4, 2008-03-05' there seems to be a typo. Line 166 is: for (i in tree.icon) tree.icon[i] = '{$this->baseUrl}/'+tree.icon[i];{$this->images} But should look like: for (i in tree.icon) tree.icon[i] = '{$this->baseUrl}/'+tree.icon[i];

I hope it was a typo and I have not broken something else but it seems to work great now.

Thanks for all your hard work Nad

Proposed Code Change for TREEVIEW5_VERSION 5.1.4 2008-03-05
This change will make arguments passed to each tree render in that tree rather than the last arguments applying to all the trees on a page.

Change Line 150 from $add = isset($args['root']) ? "tree.add(0,-1,'".$args['root']."');" : ''; to: $adds[$id] = isset($args['root']) ? "tree.add(0,-1,'".$this->args[$id]['root']."');" : '';

Change Link 167 from: $add to: $adds[$id]
 * Thanks, good spotting! actually it was a bug in line 148, where


 * needed to be changed to


 * I've updated the code to version 5.1.5 with the bug fixed :) --Nad 20:08, 6 March 2008 (UTC)

Error with Treeview5 & DPL
I am consistently getting

when trying to use DPL in conjunction with Treeview5. This is the code I am trying to use to dynamically create a listing for a Category:

The tree that is being displayed looks like I'd expect, it's just the error that's the issue.

Thoughts on what I'm doing wrong? I'm by no means a DPL expert but that appears to be working OK.

MW 1.11.2 (I was running Treeview 5.1.3 and just saw that you updated to 5.1.5 and tried that with the same results)

aldon
 * Was a typo in the code, try 5.1.6 --Nad 02:01, 8 March 2008 (UTC)
 * Perfect! Thanks,aldon

$wgOut->addScript(...) for adding JS in Treeview5.php produces invalid xhtml
The following is invalid xhtml (and breaks everything until an explicit closing SCRIPT tag is found): <script src="..." /> It needs to have an explicit closing tag: <script src="..." > Tim Laqua talk 02:44, 8 March 2008 (UTC)
 * Thanks, I've added the closing tag --Nad 09:44, 8 March 2008 (UTC)

Internet Explorer 7 not rendering tree view
Hello Nad, I have just installed treeview5 (latest version 5.1.7) and it is working fine on firefox but is not rendering in IE7. Indeed, the same happens when I try viewing pages from organicdesign so it's not related to my installation. The IE error log that show up in the bottom left hand corner says: "object doesn't support this property or method". I have tried this from two different computers. --Apap 18:56, 8 March 2008 (UTC)
 * Thanks for letting me know, I'll see if I can figure out what's up with it asap --Nad 06:02, 9 March 2008 (UTC)
 * Found the problem, in IE the JS object identifier names are not allowed to be the same as element id's --Nad 06:22, 9 March 2008 (UTC)
 * Have you uploaded the new Treeview5.php? Even though the link says 5.1.8 the actual php file still says 5.1.7 inside. I tried it but it has not resolved my IE page renderinng (though organicdesign renders correctly now). Thanks! --Apap 16:54, 9 March 2008 (UTC)
 * Doh - sorry no I hadn't uploaded the 5.1.8 changed - done now :-) --Nad 20:14, 9 March 2008 (UTC)

TreeView not rendering at all
Hi, I updated my MW from 1.9.2 to 1.12.0 and was forced to update TreeView from Version 4 to 5.1.9 therefore, too. Then I discovered that the tree wouldn't be rendered anymore at all. The rest of the page is shown without problems, except an error in the browser. I checked that and found that the problem could be caused using windows as server os. The path is built in windows notation.

part of the browser page source code <script type="text/javascript" src="/wiki/skins/common/wikibits.js?116"> <script type="text/javascript" src="C:\Wiki\xampp\htdocs\wiki\extensions\Treeview5\dtree.js"> <script type="text/javascript" src="/wiki/skins/common/ajax.js?116">

The followng line(57) in treeview5.php causes the problem rendering the path in "C:\Wiki\xampp\htdocs\wiki\extensions\Treeview5": $this->baseUrl = preg_replace('|^.+(?=/extensions)|',$wgScriptPath,$this->baseDir);

The used parameter is set: $wgScriptPath = "/wiki";

I changed your code to the following quick hack and it works now: $this->baseUrl = '/wiki/extensions/Treeview5';

It would be nice if you could check that and give me a quick reply how I should proceed. Thanks in advance. --Chrislee 15:06, 22 March 2008 (UTC)
 * Looks like it is the backslashes in windows which are forward slashes on *nix that are not accounted for in the regular expression. The preg replace would need to be something like

$this->baseUrl = preg_replace('|^.+(?=\\extensions)|',$wgScriptPath,$this->baseDir);
 * to work --Zven 21:56, 22 March 2008 (UTC)

what works for me is the following, slash-agnostic line, not verified on *nix though (--Dannyh 22:06, 25 March 2008 (UTC)): $this->baseUrl = preg_replace('|^.+(?=extensions)|',"$wgScriptPath/",$this->baseDir); I have the same problem, but all of the above workarounds produce an "unterminated string literal" error on the page at this line in the rendered html: for (i in tree.icon) tree.icon[i] = 'D:\Web Applications\DevWiki\extensions\TreeView5\'+tree.icon[i]; Any ideas? --Snuck 02:18, 28 March 2008 (UTC)

OK, by fiddling with our $wgScriptPath, and utilising Zven's solution, dTree.js now loads via <script type="text/javascript" src="/extensions\TreeView5/dtree.js"> and the expand/collapse behaviour now works, but none of the images display. I believe the problem is still with this line in the rendered html: for (i in tree.icon) tree.icon[i] = '/extensions\TreeView5/'+tree.icon[i]; The images are in --Snuck 04:52, 28 March 2008 (UTC)

The only way I could get it to work with the images loading was to change line 70 from $wgOut->addScript("<script type=\"$wgJsMimeType\" src=\"{$this->baseUrl}/dtree.js\"> \n"); to $wgOut->addScript("<script type=\"$wgJsMimeType\" src=\"/extensions/TreeView5/dtree.js\"> \n"); i.e., by hard-coding my baseUrl; otherwise, it is output as The rest of TreeView5.php is as per the OrganicDesign site; i.e., without using any of the above workarounds. This makes no sense to me - it appears that  set in line 57 has a different value when it is used in line 70 from when it is used again in line 181, but I can't see anywhere where its value could be changed. I'll keep looking... --Snuck 00:30, 31 March 2008 (UTC)
 * I suggest another approach (which I haven't tested),  is the problem because it contains a windows path with backslashes instead of forward slashes, and on windows they can be either (http://nz2.php.net/manual/en/function.dirname.php). If you convert these to forward slashes before   (approximately line 59) then the path will be constructed like a unix path.

So change the block to Any feedback on whether this works would be useful. --Zven 00:50, 3 April 2008 (UTC)

I had the problem and it's ok now. Thank you very much. --Teriblus 08:27, 14 April 2008 (UTC)
 * This problem should be fixed in version 5.1.10 --Nad 23:01, 14 April 2008 (UTC)

Experienced the same problem, even when using 5.1.10. Images were not loading, pointing to broken URL when loading: http://mydomain:8080/wikiextensionsTreeview5/img/base.gif

added the baseDir fix above and it works now, points to: http://mydomain:8080/wiki/extensions/Treeview5/img/base.gif --Fpsaceo 14:16, 22 April 2008 (UTC)

Category tree
Hi, Is it possible to mix this extension with the category tree extension ? --Teriblus 08:33, 14 April 2008 (UTC)
 * You can achieve similar results by combining treeview with DPL, see http://semeb.com/dpldemo/index.php?title=Treeview_extension --Nad 22:42, 14 April 2008 (UTC)

No custom icons in 5.1.10
Hi, it seems it's not possible to specify custom icons for single elements in the list. going through the code, it seems that this is not implemented (at least there is no call to method add with a custom icon set). Line 157 would need to be extended to add an icon if needed. will try to investigate this. Jhf2442 21:16, 19 April 2008 (UTC)

Mozilla Dev's are breaking the Sidebar Mod with Firefox and Camino Nightly's
You might want to jump into the discussion here. --Cooknn 15:20, 21 April 2008 (UTC)

Entire site reduced to blank page!!!
Current configuration:


 * MediaWiki:1.12alpha
 * php:5.2.3 (cgi-fcgi)
 * MySQL:5.0.27-log

I have downloaded and install all of the latest files but everytime in include the extension on my site I get a blank page. I comment out the 'require_once' line and all returns to normal. I've checked everything I can think of.

Help Please.......

Blank page after updating treeview5
I updated to latest treeview5 and now my site goes blank. Didn't happen with older versions of treeview5.

--Apap 19:46, 11 May 2008 (UTC)
 * What version of TV5 were you on when it was working? also TV5 is now replaced by TreeAndMenu but I haven't had time to redirect this page and update notes etc. --Nad 21:34, 11 May 2008 (UTC)
 * I was using version 5.1.9. However, I also made an attempted upgrade to mw 1.12 (without updating tables) and then went back to 1.11.2 so I don't know if something went wrong in the process. Unfortunately, I did not save treeview5 ver5.1.9 to check if it works ok. Can I try TreeAndMenu.php? Thanks --Apap 21:49, 11 May 2008 (UTC)
 * I tried TreeAndMenu.php (replacing Treeview5.php but retaining the old name) and it resolves the blank page problem. --Apap 23:37, 11 May 2008 (UTC)

Putting treeview in different place in sidebar
I used the example on the page, problem is I don't want it to go under the toolbox. I want my NavTree to be inplace of the current bullets navigation thing, above my searchbar and I just can't figure it out.

-141.157.90.165 05:44, 14 May 2008 (UTC)
 * You'll probably need to edit your skin file for that, see Manual:Interface/Sidebar for more detail --Nad 10:58, 14 May 2008 (UTC)


 * This worked great, thanks. Results are at http://www.kill-hannah.com. I'm going to try to arrange the text within the tree a little differently, sorta like you have it on organic design.


 * -141.157.90.165 19:35, 15 May 2008 (UTC)

Small comment, for a large tree you can't entirely control the space it takes up, in this case it is quite convenient to put it in the toolbox location. From memory you can enclose the tree in a; [your tree parser function syntax] However you don't want the nodenames to be to long or they get clipped... --78.49.107.231 23:24, 17 May 2008 (UTC)

Add more than one tree to article?
I am using mediawiki 1.12 on a windows server and there it does not seem to be possible to add more than one tree to one article. The first one gets displayed correctly, but the other ones are empty. Is there any chance to make this work? -- Markus
 * Looks like a bug has crept in somewhere there, I'll get that fixed as soon as I can --Nad 21:26, 14 May 2008 (UTC)
 * Ok problem should be fixed, try version 1.0.1 --Nad 22:14, 14 May 2008 (UTC)
 * Works, Thanks. -- Markus

Not being displayed in Sidebar
Hi. I installed the TreeAndMenu extension and it works on a normal page but when I edit MediaWiki:Sidebar it doesnt show up on the left side. BTW: I did not modify any css (currently no folder icons are displayed but that is not so important) and to test it I switched to monobook skin using preferences in the wiki interface. I use MediaWiki 1.9.3. When I add $wgHooks['MonoBookTemplateToolboxEnd'][] = 'wfNavTree'; function wfNavTree { global $wgUser,$wgTitle,$wgParser; if (is_object($wgParser)) $psr =& $wgParser; else $psr = new Parser; $opt = ParserOptions::newFromUser($wgUser); $nav = new Article(Title::newFromText('NavTree')); $out = $psr->parse($nav->fetchContent(0,false,false),$wgTitle,$opt,true,true); echo '&lt;/ul>&lt;/div>'.$out->getText; return true; } under the include and I edit the page NavTree I get a tree view under the toolbox but I like to edit the navigation box

Can anybody help me?


 * Ok I found out somebody posted that issue before but I didnt know that I have to edit the skin's php code like said in Wikitext in side bar
 * Thanks anyways
 * Just for those who want to have the same like I was looking for (a tree view in navigation): you dont need the function wfNavTree. Only Wikitext in side bar. 

No tree displayed on page
Used Versions : WindowXP SP2 Mediawiki : 1.12.0 PHP : 5.2.5 MySQL : 5.0.51a TreeAndMenu 1.01

Created page with #tree and #menu

Menu work fine but Tree give an fire fox error console "dTree not defined" Is it possible to have a problem of antislash (\) on different path All modifications or suggestions given in this talk dont work

Note : no tree displayed in sidebar of course

Can anybody help me ? Claude Gillet 20 May 2008
 * It's most likely that the dTree javascript isn't loading. Look at the source of the page and check the path its trying to load dTree.js from. If the site is available on the net let me know the URL and I'll have a look. --Nad 00:03, 21 May 2008 (UTC)

I have pretty much the same problem - I installed it new and nothing is happening...www.goerasmus.eu - I used the standard folders. Thanks! --Jorgusch 13:21, 7 June 2008 (UTC)

Multiple trees failing
Hi Nad A first, thanks very much for your job. To have a good running with this extension i have made a modification in Treeandmenu.php file  because the variable baseurl was not correctly evaluated (i m not a spécialiste but i have seen this in html source code generated). My wiki site is not available because internal factory site (Converteam factory). Please help my because my modification is not standard. More, i have another problem : it is impossible to have several tree on the same page (or/and on sidebar). Finally, is there a solution to place the tree anywhere in the sidbar ? Thanks to reply. CGT 01/06/08
 * What you want is a way to overide the property for the instance of the TreeandMenu class from something you put in the LocalSettings.php without having to hardcode anything into the extension itself, this gives your code independence of any further developments.


 * More than one tree can be added to an article at any time, the code automatically allows this, there is an option id= which if specified makes the trees current state persistent sing cookies, to test this, open up two browser tabs of the same article with a persistent tree on it, modify the state of the tree on one article, then reload the other articles in the other tab --Zven 23:32, 31 May 2008 (UTC)


 * Thanks for your quick answer. Unfortunately, my poor english dont permit me to understand all very well.
 * So at first, is my modification on baseurl valid ? and why the original code dont work in my configuration
 * Second how i use exactly the "id" option because my test dont work (same id for all tree ...)give me an exemple please
 * for the place of the tree on the sidebar i must test again relatively to talk above
 * Thanks verry much CGT 01/06/08
 * Not sure what the problem is with your localhost setup, there appears to be a mistake in your code  should have been   ://....

However thebaseUrl variable is a relative path to the treeview directory, not an absolute path; The id option jsut adds a unique tag to the GUIDs for each tree. See my working example, making two windows of the same article, then manipulating one and pdating the other using browser refresh should update the other. --Zven 00:51, 1 June 2008 (UTC)

Hi Nad, Zven I confirme that in my configuration, it is impossible to have more than one tree in article. In detail, the render of the first tree is OK but not for the second (no tree). Effectively, the generated HTML code is not correct (only one tree appear. In fact it is more complicated. The behaviour is very courious. The second tree work well until i add an item in the first tree (the second tree disappear!). The same thing with three tree, the add of one item in the first tree disappear the second but not the third. In your opinion, is it a problem with my configuration (or utilization) or a bug in treeandmenu ? Note : your exemple in organicdesign don't use more than one tree. Have a concret exemple with several tree ? Note : my error console indicate and

Please can you help me because the use of treeandmenu is fundamental for me. Claude Gillet 04 june 2008
 * Can you give me a URL of the site? if if not public, add the wikitext source and the html source of the problem page to my talk page and I'll take a look --Nad 13:14, 4 June 2008 (UTC)
 * Ok I've found the problem, update from SVN and your multiple trees should be working now --Nad 01:21, 5 June 2008 (UTC)

Hi Nad

Thanks for your reactivity. The Multi tree work now well but : is always in my error console
 * it is impossible to use the option (root=, id=, ...) because trees disappear
 * The message

In exchange to your work, i propose to complete the extension documentation to have more explanations for the newby

Regards. CGT 05/06/08

Customizing width and position
Hi. Thanks for your work. Question: Are there parameters like width so I can pass in the template a different width according to the particular tree? This is relevant for example if your tree is on the right part of the page. And same for position? - 22.05.08
 * Give your tree an id parameter and then you can address it specifically in your CSS --Nad 21:14, 22 May 2008 (UTC)

Customizing the root
Hi. I could not find a way to add a mediawiki link in the top root? Like

Thanks - 22.05.08
 * bug fixed, root parsed as wikitext properly now --Nad 13:58, 4 June 2008 (UTC)

Remove the root
How can I remove the "root line" and icon completely as in the example on the DPL website?
 * Set the root image to nothing in your localsettings, $wgTreeViewImages['root'] = "" --Nad 22:04, 3 June 2008 (UTC)