I needed to have more flexibility in using WebFM for one of my projects.. and it became the following general purpose change that I want to donate back to the community.

The patch attached to the next comment is designed to make WebFM easier to use in themes, modules, and custom blocks. This is basically done by adding a new webfm_custom_layout function to the webmf.module and changing code needed in the PhP and JavaScript needed to support this.

Here's a quick overview of the function and it's arguments that can change the various aspects of webfm's output.

function webfm_custom_layout( $path = NULL, 
                              $displayTree = NULL, 
                              $displayDir = NULL,
                              $breadcrumbRoot = NULL,
                              $displayColumns = NULL )
                              
$path              The "current" directory to use.  This is the path as a normal user would see it.  E.g. /roleDir/subdirA/subdirA1
                      
$displayTree     If false, suppress the folder tree display on left.

$displayDir        If false, suppress the directory list on right.

$breadcrumbRoot    A path used to "truncate" the dir list breadcrumb. E.g. /roleDir/subDirA will cause the breadcrumb display 
                           to start with /subDirA.  Useful to "psuedo-lock" users to a subtree.

$displayColumns    An array of "column_name => boolean" that determines which columns to display. "column_name" is one of:  
                          name, modified, size, or owner.  A true value = display (the default). A false value = do not display.
                          Generally, you only need to turn off column.  E.g. array( 'modified' => false) will display the other three.  
                          Note, if the owner column is turned off in the admin, it will never be displayed.

Returns            The HTML outout to display webfm.

Here are some usage examples to help clarify how to use this:

CASE: Display normal WebFM display but show a specific directory

You want to display a normal WebFM type page but have a different default directory.

1) Create a node or custom block using the PhP Input filter.

2) Add the following PhP code as the body. (assumes WebFM module installed)

<?php
   $path = '/MyRole/MyFiles';             //Current path
   print webfm_custom_layout($path);
?>

3) Set up required navigation/conditions to this node or block.

CASE: Display only the documents related to a specific product.

Product document on a website are maintained by the DocManager role. They are uploaded via the normal WebFM process into a directory like:

/ProductManager/MyProduct

This has subdirectories like SalesInfo, Manuals, etc.

You want to use WebFM to allow normal users access to just the MyProduct area and its subdirectories.

1) Create a node or custom block using the PhP Input filter.

2) Add the following PhP code as the body. (assumes WebFM module installed)

<?php
   $path = '/ProductManager/MyProduct';             //Current path
   $displayTree = false;                            //Don't display left hand folder navigation
   $displayDir = true;                              //Do display right hand directory listing
   $breadcrumbRoot = '/ProductManager/MyProduct';   //Limit directory listing breadcrumb to this. 
   print webfm_custom_layout($path, $displayTree, $displayDir, $breadcrumbRoot);
?>

3) Set up required navigation/conditions to this node or block.

CASE: Need a WebFM display of files in a directory for a sidebar.

You need a sidebar block that will list files in a directory. This means that the normal display is too wide, so you want to just display the name column.

1) Create a custom block using the PhP Input filter.

2) Add the following PhP code as the body. (assumes WebFM module installed)

<?php
   $path = '/MyRole/MyFiles';             //Current path
   $displayTree = false;                  //Don't display left hand folder navigation
   $displayDir = true;                    //Do display right hand directory listing
   $breadcrumbRoot = '/MyRole/MyFiles';   //Limit directory listing breadcrumb to this. 
   $displayColumns = array( 
                     'owner' => false,    //Don't display owner column (if enabled)
                     'modified' => false, //Don't display date modified column
                     'size' => false, );  //Don't display size column
   
   print webfm_custom_layout($path, $displayTree, $displayDir, $breadcrumbRoot, $displayColumns);
?>

3) Set up required navigation/conditions to this node or block.

Important Usage Notes:

The file display will still follow the standard WebFM security rules. E.g., Nothing will be displayed unless the user has at least "Access" rights.

THERE CAN BE ONLY ONE... WebFM display on a page. E.g., you can't have two custom blocks that display different directories.

Extra Credit:

You can also change display options via embedded Javascript on the page. See the Webfm.options variable in the webfm.js file.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

cgmonroe’s picture

Here's the patch built from the current CVS head. In addition, since it's a fairly complex patch, I've include a Patch change log to make review easier.

robmilne’s picture

Status: Active » Postponed

Wow, this is an excellent piece of work. Do you have links to examples of the cases?

I like your addition of the Webfm.options array. I'm wondering if it should be integral rather than an optional inline tack on. That way I can dispense with the owner column control in the admin area and replace with a general set of controls for all columns.

I will be releasing a 2.12 soon to apply some recent fixes but I won't add this yet. I like what you have done but I need to reacquaint myself with the module (de-engineer my own code) to decide what to do. The js needs refactoring.

cgmonroe’s picture

Thanks! Unfortunately, I don't have any public links. This has been used in internal/protected client areas.

Only issue I can think of about making it internal is that it might limit JavaScript based options (e.g. can't override the Ajax data being returned with JS on page). E.g. suppose you wanted to wrap a WebFM display with some JS code that changed it's looks. But to be honest, it's really that way because I started this by looking at how I could override your JS classes/functions with a subset of mine. Then it became easier just to mod it directly.

Maybe a way to keep this flexibility and allow for the new admin options, would be to set the default options using the current inline JS that the main() function already adds. Then the defaults can be overriden by setting the desired valued after this.

FYI - I am also looking at expanding this to allow for better OG support (group specific blocks, etc). Not sure if this will be a new module or another patch. It may evolve into a WebFM Node content type with security based on node access. I'm thinking this would be nice for personal files (a profile node) and easily putting groups of user manageable files into a site where you want them.

cgmonroe’s picture

FileSize
23.86 KB

New Patch file that has been updated for use with the 6.x-2.12 release (based on CVS head as of today).

Patch change log (Comment #1) is the same except for the trim statements in HTTPRequest.

cjdavis’s picture

Is there any update on including this patch in the next release of webfm? This appears to be exactly what I need to integrate a webfm display on an organic groups page itself.

nhck’s picture

Status: Postponed » Needs review

+adjust category. this shouldn't fall off the cliff

RdeBoer’s picture

Agree with #2, #5. This is excellent and deserves to become part of the next release.
If the config options (path, displayTree, breadcrumbRoot etc.) could be set from the Administer >> Site configuration >> Web File Manager page then even better!

cgmonroe’s picture

FileSize
19.92 KB

I needed some of the features/patches from the current dev version. In updating my code, I created a new patch version that works with the current HEAD or dev version. It's attached.

This contains the same changes as above with the following changes:

JavaScript modified to support turning off directory trees works for in attachment display.
JavaScript includes "GUI Enhancements" listed in issue: #859488

FWIW - I've been using this is a couple of site with lots of people and haven't found a problem.

Also, I've got a "webfm-og" module in the work that uses this patch to supply a lot of common things people who use OG and WebFM have been asking for. E.g. Home page webfm block that defaults to OG current directory, a group files page, make the current directory for items being posted to a group be the group file store, and some other stuff in the planning stages. But I'm waiting until this is officially in webfm... (yes, this is a bribe...lol...).

leapy’s picture

Hi

I see the current WFM development release is dated 2010-Aug-19.

I am still finding my feet with Drupal and I am trying to work out if this patch is now included in the above release? I assume not since #736548 is not mentioned in the notes but need to confirm.

Sorry if this is the incorrect place to post this question. Can't find anywhere applicable in the forums.

Thanks

cgmonroe’s picture

Status: Needs review » Reviewed & tested by the community

Unfortunately, it hasn't been committed yet. But there are patches for both the 6.x-2.12 (Aug 19, 2010) release and the dev head listed above.

FWIW - since I'm using it in several production sites without problems and others seem to be using it, I'm changing the status to reviewed and tested... (OK probably not PC to do this for my own code, but...).

leapy’s picture

OK. Thanks for the feedback.

Now, all I need to do is learn how to apply patch files... I am assuming that this is like "normal" code patching not some Drupal-specific thing.

Lee

nallasivamkn’s picture

Hi all,

I am very new to Webfm module. I want to add two more columns in webfm front end display... currently it is displaying Name, Modified, Size and Owner of the file/folder, but i want to add two more columns. One is for displaying the file created date and another one is for user, who last modified that file....

Can anyone help me....

Thanks in advance....

nhck’s picture

Version: 6.x-2.11 » 6.x-2.x-dev
Priority: Normal » Major

cgmonroe,
sorry for neglecting this patch this long! Care to do a rerun against the current -dev? As you see I have done much code cleanup and already committed most of your other patches. It would be nice to have a patch that focuses on just implementing this functionality.

Thank you for helping out this much with webfm, really.

cgmonroe’s picture

I'll see if I can't find the time to do this soon... this week has been lost to fighting fires at work...sigh.

robmilne’s picture

Seconding #13. I have cycles to give to the module again but I'll wait until Niels commits your patch.

-rob

cgmonroe’s picture

FileSize
23.87 KB

I finally found the time to build and test a patch for the current CVS head.... Here it is.

robmilne’s picture

Status: Reviewed & tested by the community » Fixed

The changes inside the patch have been committed to head - also added administrator display options for enabling the date and size columns of the right-hand directory listing. Restored my original whitespace styling in webfm.js. Fixed iframe src inside the selectFile function of webfm.js.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

t-readyroc’s picture

Version: 6.x-2.x-dev » 6.x-2.18
Category: feature » support
Priority: Major » Normal

Glad to have found this - I was pointed to it from a link in another issue thread. Any reason this isn't in the documentation/readme?

At any rate, here's my issue: I've successfully created & displayed a custom block that I've added to the group-home context (I want to display the group's "home directory" on the group home page). The block is displaying and functional, but none of the arguments I've specified are getting passed. Here's my block's "body" code:

   $displayTree = false;                  //Don't display left hand folder navigation
   $displayDir = true;                    //Do display right hand directory listing
   $displayColumns = array(
                     'owner' => false,    //Don't display owner column (if enabled)
                     'modified' => false, //Don't display date modified column
                     'size' => false, );  //Don't display size column
   
print webfm_custom_layout($displayTree, $displayDir, $displayColumns);

Like I said, the full block is there. The problem is, the tree's showing, as well as the owner, modified, & size columns (like the full-on viewer, but squished due to size constraints). Any help would be appreciated.