Installed WebFM 5.x-1.11 on Drupal 5.2. Created subdir named testdir within webfm directory then uploaded a file named 52-12-avr07.pdf and added metadata (file description=52-12) to the file. Created a view to display all files that contains a specific file description but no files are displayed. Am I missing something?

Here's my view:

$view = new stdClass(); $view->name = 'WebFMview'; $view->description = 'Webfm view desc'; $view->access = array ( ); $view->view_args_php = ''; $view->page = TRUE; $view->page_title = 'the title'; $view->page_header = ''; $view->page_header_format = '4'; $view->page_footer = ''; $view->page_footer_format = '4'; $view->page_empty = 'Aucun fichier!'; $view->page_empty_format = '4'; $view->page_type = 'node'; $view->url = 'webfmview'; $view->use_pager = TRUE; $view->nodes_per_page = '10'; $view->sort = array ( ); $view->argument = array ( ); $view->field = array ( array ( 'tablename' => 'webfm_file', 'field' => 'ftitle', 'label' => 'Description', 'sortable' => '1', 'defaultsort' => 'DESC', ), array ( 'tablename' => 'webfm_file', 'field' => 'fname', 'label' => 'Filename', 'handler' => 'webfm_views_handler_file_filename_download', ), array ( 'tablename' => 'webfm_file', 'field' => 'fsize', 'label' => 'Size', ), ); $view->filter = array ( array ( 'tablename' => 'webfm_file', 'field' => 'fdesc', 'operator' => '=', 'options' => '', 'value' => '52-12', ), ); $view->exposed_filter = array ( ); $view->requires = array(webfm_file); $views[$view->name] = $view;

Comments

clauded’s picture

Ok I think I found why : the files need to be attached to a node before being displayed in a view.

Would it be an good feature to permit to display files in a view that are not attached to a node? I think then this query should be changed (in webfm_views.inc) :
$query = "SELECT wf.* FROM {webfm_file} wf INNER JOIN {webfm_attach} wa ON wf.fid = wa.fid WHERE wa.nid = %d ORDER BY %s";
to
$query = "SELECT wf.* FROM {webfm_file} wf ORDER BY %s";

A configuration option to activate the feature could be used...

andremolnar’s picture

Status: Active » Closed (fixed)

Rob brought my attention to your issue - but I'm glad to see you've sorted it out.

Yes - views acts on nodes. Therefore, in order to harness the power of views for your needs and have this information exposed to a view, it must be associated with a node.

e.g. Show me all files that are greater than 3 megs with 'of montreal' in the file description attached to video nodes.

What I think you are looking for is some sort of filtering tool that acts/depend only on the data in the webfm_file table. I think there's an opportunity there for a contributed module that does that sort of thing. In other words, the best course of action would be to write a module that does what you need. Two functions would do it - hook_menu and the function to display the info.

andre

robmilne’s picture

Status: Closed (fixed) » Active

I have deferred your question to Andre Molnar who developed the views portion of the module. You are correct that views info is available only for attached files. Removing this restriction is a good suggestion and would increase the potential for metadata datamining.

robmilne’s picture

Status: Active » Closed (fixed)

Setting the status back to closed after my near simultaneous posting with Andre.

KathyIce’s picture

Can you tell me if anyone has implemented this functionality?

I want to give my users access to a hierarchical directory of files (too many to attach to nodes... and attaching to nodes seems to put all the files in a single directory, which is unwieldy for 1000 files... and the directory system will grow over time.)

WebFM does a nice job of letting users browse the whole tree (as do some other file browser modules).. but I would like to have some nodes provide direct access to the subdirectory that relates to the given node. I haven't found a module that does this... I was hoping the Views capability of WebFM would do that.

robmilne’s picture

Unfortunately views only works with nodes. I've created the functionality you want but it requires custom module work. This custom module could have an admin setting that stores a directory path which is used by the module to access files. If you look at the recurse_build_tree function you will see that the recursive function can build an object that includes the files beneath a given path. The module could use this function to get everything below the specified path and do something (ie: display lists with links) based on directory name, file type, etc.