File List

Summary: Tabulated filelist markup as alternative to (:attachlist:), for a simple, easy readable look. Version: 2007-09-01a Prerequisites: pmwiki 2 Status: new Maintainer: HansB? Categories: Uploads Download: see Cookbook:FileList

Questions answered by this recipe

How can I have a simple, easy readable file list?

This section is optional; use it to indicate the types of questions (if any) this recipe is intended to answer.


(:Description FileList adds markup for a clean looking tabulated file listing as an alternative to the attachlist markup:)

Download Attach:filelist.php Δ and dot3.png Δ, copy filelist.php to cookbook directory, and dot3.png to your Farm/pub/images/ directory. Install in config.php with ->include_once("$FarmD/cookbook/filelist.php");

Use markup (:filelist:) to see a list of attached files.

Sample image of a filelist (with European style date formatting): Attach:filelist-sample.gif Δ

Set $FileListTimeFmt for your preferred date & time format. For example:

$FileListTimeFmt = '%d %b %Y'; - day short month year
$FileListTimeFmt = '%B %d, %Y'; - long month day, year
$FileListTimeFmt = $TimeFmt; - PmWiki default time format


filelist.php includes a modification of the FmtUploadList function from scripts/upload.php.

The dot3.png image is used purely stylistically to provide a line of not too obtrusive dots between the file names and the file sizes, to aid the eye.

File sizes display as shorter Kb instead of more exact but longer byte sizes.

Sortable FileList

I'm uploading filelist_sortable.php Δ It's a Modded version of filelist.php which uses the sorting functionality of AttachListSort.php

Basically this allows you to have the presentation of FileList while having the sorting functionality of AttachListSort. So for example, you can type (:filelist sort=date:) and it'll sort by date. All of AttachListSort's syntax (as it was on 2008-02) works.

What's in it

I created it by copying the function from AttachListSort.php into FileList.php, adding a few lines to call the function, changing the sorting function to return only the ordered filelist, and commenting out some now-redundant code.


To install filelist_sortable.php Δ, just download it into your cookbook folder, comment out (using a number sign (#) before the line) or just take out any include lines you made for filelist.php or AttachListSort.php and insert an include line like


'''Don't forget to download dot3.png Δ and put it in your /pub/images/ directory (that is, if you haven't already).'''

Release Notes

  • 2008-02-20: Uploaded filelist_sortable.php
  • 2007-09-01a: Added $FileListTimeFmt, to provide easier means to change the date & time displayed.
  • 2007-09-01: Initial release.

If the recipe has multiple releases, then release notes can be placed here. Note that it's often easier for people to work with "release dates" instead of "version numbers".


Hi. thanks for this - it looks/feels nice. however, i noticed that while FileList seems to work great with pages that already have files uploaded to them, it malfunctions when added to a page with no uploaded files - it produces this error:

  • Warning: Invalid argument supplied for foreach() in /my/directory/pmwiki/cookbook/filelist_sortable.php on line 218

I found that providing the simple conditional if($filelist) { foreach($filelist ...) } seemed to counter this error on my end...

Also, two suggestions for coders more able than I:

  • I wonder - how challenging would it be to incorporate the renaming & deletion capabilities of Attachtable?, which doesn't have the fancy sorting capabilities found here?
  • And, is it at all possible to give FileList (or any of the other filelisting flavors) the same fmt=# capabilities that (:pagelist:) has. it would be amazing to be able to reference a custom pagelist template for file display...

Just some ideas overtones99 (2008-03-05)

If I remember discusssions about this correctly, filelist has quite different needs than pagelist, and it is not very feasible to port pagelist capabilities to filelist. So anything for file listing needs to be developed separately. HansB?

See Also