FileList

Summary: Tabulated filelist markup as alternative to (:attachlist:), for a simple, easy readable look.
Version: 2017-06-20
Prerequisites: pmwiki 2.2.56 (compatible with PHP 5.5)
Status: stable
Maintainer: HansB
Discussion: FileList-Talk
Categories: Uploads PHP55 PHP72

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 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):

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

Notes

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.

Installation

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

include_once("$FarmD/cookbook/filelist_sortable.php");

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

Release Notes

  • 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 Also

Contributors

Comments

See discussion at FileList-Talk

User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.