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.
FileList adds markup for a clean looking tabulated file listing as an alternative to the attachlist markup
Download 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 ->
(:filelist:) to see a list of attached files.
Sample image of a filelist (with European style date formatting):
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.
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
- 2017-06-20: Updated markup definitions for PHP 7.2 compatibility.
- 2014-02-22: Updated markup definitions for PHP 5.5 compatibility.
- 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".
See discussion at FileList-Talk