Resource types

 
 
Picture of Marcus Lauer
Files in Folders: Always folded out as default?
 

Hello,

Files in Folders: Always folded out as default? For example: I have uploaded 5 folders with each 50 files. Moodle (2.2.2) always shows an "endless" list. For the user this view is very confused.

Are there any options for moving in / fold in the subfolders? It would be great to have a view who only shows a list with all subfolders. So the user can fold out the subfolders as desired.

Any hints?

Marcus


 
Average of ratings: -
Picture of Jean Michel
Re: Files in Folders: Always folded out as default?
 

In my case, I create a resource file that contains several files and folders, but when I go to the course view I can only see the first of them. I don't know if it depends on the theme I have selected, of if it can be configured (Ididn't configure anything for this). 

I think you are doing it in another way... you are creating a resource of type folder and after this, you are adding the files. Am I wrong?

Regards.-Jean

 
Average of ratings: -
Picture of Marcus Lauer
Re: Files in Folders: Always folded out as default?
 

Hello Jean,

yes I create a folder with several files in it. Or I take a ZIP which includes several folders and files and I extract it (in the folder I created before).

But in all ways - I always get the files listed. It would be great to change the view. Sometimes this list is useful. But if you have a lot of files the user looses overview. So it would be useful to activate (unfold) the subfolders manually.

 
Average of ratings: -
Picture of Jean Michel
Re: Files in Folders: Always folded out as default?
 

Ok. In that case you can use this patch:

open your <moodle_root_dir>/mod/folder/renderer.php file.

Find the function render_folder_tree. In my moodle 2.2 I have this line:

 $this->page->requires->js_init_call('M.mod_folder.init_tree', array(true));

The last parameter indicates if the tree is expanded (true)/collapsed (false) by default. Now it is true, change that string to "false". So the line is:

 $this->page->requires->js_init_call('M.mod_folder.init_tree', array(false));

I think this should be a config option for the module, so people could change this using site administration>plugins>folder preference.

Best regards.

Jean

 
Average of ratings:Useful (2)
Picture of John Holmes
Re: Files in Folders: Always folded out as default?
 

Jean,

Thanks so much.  I was looking for the same solution.

Do you know if this is already a feature request?  I agree, it would make sense for this to be a config option for the module.

At the moment, the only config is require "description".

 
Average of ratings:Useful (1)
Picture of Colin Wheelhouse
Re: Files in Folders: Always folded out as default?
 

The script change above works great but closes all folders. Why is there a top level folder which then contains the folder you have created? Is there a way to either a) get rid of the top level folder or b) have the top level folder open and all subsequent

folders trees closed.

 
Average of ratings:Useful (2)
Picture of Chris S
Re: Files in Folders: Always folded out as default?
 

I too am finding this to be an issue and am currently looking right now to work away around this, as you say if the top level folder was open that would be great.

 
Average of ratings: -
Picture of Pieterjan Heyse
Re: Files in Folders: Always folded out as default?
 

Did someone open a feature request in the tracker about this?

 
Average of ratings: -
Picture of Florian Zillner
Open Top folder upon load
 

According to Jean Michels hint, open your <moodle_root_dir>/mod/folder/module.js file.

If you do not want to edit two files, just edit this one. Find the if conditional which checks for the expand_all option and comment out the following line.

if (expand_all) {
   //tree.expandAll();
}

Next, to select the top folder to be opened on page load, add right before the call of the render() function the following line:

tree.getNodeByIndex(1).expand();
tree.render();

Your whole module.js file should look like this:

 

/**
* Javascript helper function for Folder module
*
* @package mod
* @subpackage folder
* @copyright 2009 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

 

M.mod_folder = {};

 

M.mod_folder.init_tree = function(Y, expand_all) {
Y.use('yui2-treeview', function(Y) {
var tree = new Y.YUI2.widget.TreeView("folder_tree");

 

tree.subscribe("clickEvent", function(node, event) {
   // we want normal clicking which redirects to url
return false;
});

 

if (expand_all) {
   //tree.expandAll();
}
tree.getNodeByIndex(1).expand();
tree.render();
});
}

 

 
Average of ratings: -
Picture of Kalle Nielsen
Ang: Open Top folder upon load
 

Jean Michels patch works fine - but we need the first level to be unfolded. Tried Florians suggestion.

Commented out as this:
   //tree.expandAll();

Added as suggested 
tree.getNodeByIndex(1).expand();

It didn't help - still the top folder is collapsed.
Others having the same problem?

 
Average of ratings: -
Picture of Florian Zillner
Re: Ang: Open Top folder upon load
 

Did you purge your Moodle caches after editing the Javascript file? I just tried it and it works as expected/said before.

 
Average of ratings: -
Picture of Kalle Nielsen
Ang: Re: Ang: Open Top folder upon load
 

THANK YOU! 
I did empty browser-cache, but had forgotten to delete Moodle server cache via /admin/purgecaches.php

It works just fine smile

 
Average of ratings: -