Old modules and plugins

Note: This database has been replaced by the Moodle Plugins Directory.

Block: YUI Course Files Directory Tree

Type: Block
Requires: Moodle 1.8 or later
Status: Contributed
Maintainer(s): Dean Stringer

Moodle block to display course files in a YUI TreeView widget. Includes a bunch of config settings that allow a teacher/admin to specify:
  • which folder from their files directory should be displayed
  • how deeply the folders should be crawled and made visible
  • what the name of the block should be
Note: This block only displays files and folders from the course files area. It does not include course activities, other resources likes web links, and broader control panel or course topic/week type navigation. You should consider existing blocks like "YUI Course Menu" for that purpose.

INSTALLATION:

This should be a standard block installation. The only external dependencies are the YUI and JSON libraries which will already be installed with Moodle versions 1.8 or later. YUI was available in Moodle v1.7 but the JSON lib was not.
  • expand the archive into the /blocks/ folder of your Moodle root
  • visit the notifications page as an admin and the block will install
BROWSER TESTING/SUPPORT:

The block should perform without problem in any browser supporting the YUI library. We have specifically tested the following combinations:
  • Windows XP : Firefox 2, Firefox 3, IE7, IE6
  • Windows Vista : Firefox 3, IE7
  • Mac OS/X : Firefox 3, Safari 3
  • Ubuntu Linux : Firefox 3
The YUI libs were first introduced to Moodle mid 2006 to support AJAX work with a major upgrade to them in Aug 2007.

IMPLEMENTATION:

The block uses an OOP approach instantiating a dir_tree object through the class file included with this distribution.

After fetching the directory data from a method in the dir_tree class the data is echo'd out to the browser encoded in JSON format so that the client can invoke and render the tree using the YUI JS libraries. A static version of the tree is also written out to the client in case it doesn't support JS.

The browser needs to load dir_tree.js (url versioned so its not cached) and the YUI JS libs, and also needs a <DIV> element to pour the tree into. The browser also needs access to the css file which contains display styles for the tree.

The block class includes methods which handle generating all the HTML for these includes.

dir_tree.js is loaded with a 'defer' switch and boot-straps itself when the YAHOO.util.Event.onDOMReady event fires which then builds the tree in the browser.

When the tree is ready for display the <DIV> in the page that holds the static non-JS version is hidden and the new tree drawn in its place. A unique ID is generated for the DIVs so we can manipulate them without worrying about another instance of a dir_tree being on the same page.

One YUI feature that did change that affects the libs as shipped originally with Moodle v1.8 is the onDOMReady was not present, I've handled this by doing a try-catch and reverting to a window.load instead

The block uses a local lang folder for the interface strings, feel free to translate these and they will be included in future releases.

The dir_tree class functionality can be used by other blocks or modules. A sample use of it is included for modifying the mod/resource/type/directory class to also use the YUI tree. The class has been written in such a way that it is only loosely connected to Moodle internals and paths, after constructing the object you simply pass the wwwroot and dataroot locations into it. It should be usable outside of a Moodle environment with little effort.

Certain special folders are hidden from display, e.g. moddata & backupdata

Icons for the various file types displayed in the tree are sourced from the main /pix/f folder of Moodle and referenced in the included style.css file.


Record added by Dean Stringer - Monday, 10 November 2008, 9:59 AM
Last modified - Tuesday, 10 March 2009, 10:22 AM

Comments

  • Picture of Barry OosthuizenBarry Oosthuizen - 6 February, 09:57
    This looks nice. Does it work with 1.9.x? I get a blank screen when going to the notifications page.
  • DeeKnowDean Stringer - 6 March, 06:03
    Hi Barry, yes it's working well for us under 1.9.3. I'll drop you an IM to see if we can work out whats happening in your install and will post whatever the problem was back here later.
  • DeeKnowDean Stringer - 10 March, 10:13
    Thanx for you help resolving the probs you were having with the install Barry. I'm going to post over in the discussion forum for this block and mention the tweaks made to sort this out, and the other changes we have since made to the block at Waikato Uni. I will also update the link to the latest version of the code.
  • Picture of Pennie BaconPennie Bacon - 27 March, 13:30
    Hi.. I have 1.9.4 and I get the blank white screen on the Notification /.. I have read all of the discussions but I cant seem to resolve the problem.
  • Picture of Christian MornardChristian Mornard - 21 April, 17:32
    I have installed the block successfully on Moodle 1.9.3 on a test machine. Now, when I try to install it on our two production servers (one in 1.9.2 and one in 1.9.3), the block appears as 'title' in the block list and the configuration page is unavailable. I assume it is a language setting issue but I can't figure it out. I have checked the language settings in Moodle and they are identical to the ones on the test server. I wonder if the problem is in the template I use, the Apache configuration or the MySQL charset and collation. The shell environment variables seem identical on both servers.

    I am running Moodle 1.9.2 and 1.9.3 on SuSE Linux Enterprise Server 10 SP2. The frontend is running Apache 2.2.3. The backend is a MySQL 5.0.26 database. PHP version is 5.2.5

    Any clue?

    Thanks in advance.
  • Picture of Christian MornardChristian Mornard - 21 April, 21:53
    For some reason, this editor converts the square brackets sad.
    The string displayed in the block list is [ [ title ] ]

  • Picture of Christian MornardChristian Mornard - 22 April, 22:34
    I am a bit further. I managed to have the block title displayed by replacing <? with <?php in lang/en_utf8/block_dir_tree.php

    Not sure why I didn't need it on my test server, though. Probably a setting in PHP.ini or in httpd.conf.

    Now, I need to understand why the config form is still not displayed. All I see is : "Configuring a Course Files block" but nothing under.
  • Picture of Christian MornardChristian Mornard - 22 April, 23:06
    Turning Moodle debugging on shows this message:
    "Parse error: syntax error, unexpected $end in /srv/www/htdocs/blocks/dir_tree/config_instance.html on line 91"

    Replacing the '<?=' with '<?php echo' solved the problem.

    Hope this helps if you come across the same issue.
  • Picture of Christian MornardChristian Mornard - 22 April, 23:36
    Found it! It is a setting in php.ini

    short_open_tag = On

    I had it On on my test server but Off on the production server.
    That permits the usage of '<?' and '<?=' instead of '<?php' and '<?php echo'

    One learns every day. It took me three days to figure this one out.

    Case closed.
  • Picture of Nadav KavalerchikNadav Kavalerchik - 12 July, 00:21
    thank you for this beautiful block smile

    i have translated it into hebrew and patched it to support RTL too
    here is a link to the rtl new version (that works fine with moodle 1.9.x btw.)
  • Picture of Alex LeeAlex Lee - 4 February, 18:44
    This looks great. I have tried installing on Moodle 1.9.7 and get these errors, with both of the downloads on this page. Any ideas?


    Notice: Trying to get property of non-object in /srv/www/htdocs/lrtmoodle/blocks/dir_tree/block_dir_tree.php on line 44

    Notice: Trying to get property of non-object in /srv/www/htdocs/lrtmoodle/blocks/dir_tree/block_dir_tree.php on line 67

    Notice: Trying to get property of non-object in /srv/www/htdocs/lrtmoodle/blocks/dir_tree/block_dir_tree.php on line 70

    Thanks
    Alex
  • nothin' to do Alberto Juliao - 22 December, 00:07
    Hello, I found this very wonderful, I installed it and adapted for a better css style, but I have a problem now, Our website uses mootools and somehow is avoiding to display the block, I went to the header.html of current theme and deleted the script line where is called the mootools.js and it showed normally, but I need help to find a way to fix this issue, I went to the block_dir_tree.php and on line 24 we have this:
    require_js(array('yui_yahoo', 'yui_dom', 'yui_event', 'yui_treeview'));
    First I commented the line and it the block appeared normally showing the files and folders, but didn't show the expandable option on folder and sub-files of folders. Then I changed the first attribute (yui_yahoo) to "yui_container" and the same thing happened, showing all files and folders but no expandable option (left icon on folders).. Is there a way to make this work with mootools? I will appreciate it so much. Thanks for reading.