4

Do you know of a Drupal module that does this: I have been searching for a solution to use in a Drupal site where the Folder Contents are Listed in a Table, exactly as described in the below description of this Joomla module.

http://extensions.joomla.org/extensions/directory-a-documentation/downloads/12249

Description: This is a simple-to-use module that is used to list the contents of a folder in either a table or a list. The folder listing can display the filename, with or without the extension, with or without the date modified and file size, as well as a icon representing the file type. It has the feature of allowing the user to specify whether the filename listed should be linked or not.

Main features:

List files in a specified sub-folder of the Joomla root Show icons for file types List files in either a table or a unordered list Option to link to the files or not

3 Answers 3

1

Maybe you have to try two modules who allow to manage files in Drupal:

The Media module provides an extensible framework for managing files and multimedia assets, regardless of whether they are hosted on your own site or a 3rd party site

  • workbench media : it's an integration of the first module in the workbench suite, that's great if you want a listing of all your files uploaded in your site.

If you just want to display files to the users, you can do that quickly with views:

  • Add a new view
  • In show section select files

After you'll be able to show all the files you have in your folder (but you can also restrict to only show files from a specific content type) I took a photo of all the fields available :

view files

2
  • Now that I read my question again it appears I did not fully qualify the use: I need a module for displaying folder contents as files in a table for front-end display to the site visitor. This request is not about managing the admin area of the CMS.
    – LoveYouFyi
    Commented Sep 22, 2012 at 13:07
  • I edited my post maybe it can help you...There're no icons for extensions but you can add it with some code in a custom template from views.
    – Epok
    Commented Sep 22, 2012 at 18:03
1

I use some simple php in a basic page. This is first draft code (doesn't take into account empty folder, etc.), YMMV, but it works for me.

<?php
$path = '/files/my-files/';
$fullPath = '/var/www/drupal/sites/default' . $path;
$myDirectory = opendir($fullPath);
$i = 0;
while($entryName = readdir($myDirectory)) {
  if ($entryName != '.' && $entryName != '..') {
    /* Change order to change sort order */
    $dirArray[$i]['date'] = filemtime($fullPath. $entryName);
    $dirArray[$i]['name'] = $entryName;
    $i++;
  } 
} 
closedir($myDirectory);

$indexCount = count($dirArray);

sort($dirArray); /* sorts by first field above */

print('<table cellpadding="5" style="width:100%" cellspacing="0">');
print("\n<tr><th>Title</th><th>Updated</th></tr>\n");
/* Reverse or forward order */
for($index = $indexCount -1 ; $index >= 0; $index--) {
  if($index % 2 == 0) $class = ' class="even"'; else $class = ' class="odd"';
    $name = $dirArray[$index]['name'];   
    $displayName = str_replace('_', ' ', substr($name, 0, strlen($name)-4));
    $icon = '';
    switch (substr($name, strlen($name)-4, strlen($name))){
      case ".doc": $icon = ' <img alt="doc" src="/images/icon_doc.png">';break;
      case ".pdf": $icon = ' <img alt="pdf" src="/images/icon_pdf.gif">';break;
      case ".xls": $icon = ' <img alt="xls" src="/images/icon_xls.gif">';break;
    }
    print("<tr$class><td><a href=\"$path$name\">".$displayName." $icon</a></td>\n");
    print("<td>");
    print(str_replace(' ', '&nbsp;', date('j M Y', $dirArray[$index]['date'])));
    print("</td>");
    print("</tr>\n");
}
print("</table>\n");
?>
1

Somehow late, but you may take a look at the "Directory based organisational layer" module.

Here is a quote about it (from the module's project page):

... adds a new organizational layer to drupal, making it easy for managing large numbers of files and nodes. It allows the creation of on the fly directory structures and upload of multiple files at once. Jpeg files are displayed as slideshows, other files can be downloaded from a block.

Not the answer you're looking for? Browse other questions tagged or ask your own question.