PmWiki | Cookbook / AttachListSort (original) (raw)

Summary: Sort an attachlist

Version: 1.7

Prerequisites: none

Status: Working

Maintainer:

Questions answered by this recipe

Description

This recipe allows you to sort the attachlist via name and/or date/time and/or size and/or file type.

Syntax is easy:

(:attachlist sort=name:) (:attachlist sort=type:) (:attachlist sort=date:) (:attachlist sort=size:) (:attachlist sort=time:) - sorting by time same as sorting by date (:attachlist sort=ext:) - same as "type"

(:attachlist sort=ascendingname:) - ascending is default direction (:attachlist sort=ascendingtype:) (:attachlist sort=ascendingdate:) (:attachlist sort=ascendingsize:) (:attachlist sort=ascendingtime:) (:attachlist sort=ascendingext:)

(:attachlist sort=descendingname:) (:attachlist sort=descendingtype:) (:attachlist sort=descendingdate:) (:attachlist sort=descendingsize:) (:attachlist sort=descendingtime:) (:attachlist sort=descendingext:)

(:attachlist sort=date ext=jpg:) sort just the jpg files

Multi-Sort

The left most parameter value has precedence when using sort.

(:attachlist sort="date size":) - Sort list by dates which are sorted by size (:attachlist sort="type,size":) - Sort list by types which are sorted by size

(:attachlist sort="name type date size":) - default sort

Case-insensitive name-sorting

By default, the sort method by name IS SENSITIVE to case. That means all filenames where the first letter is capitalized will come before all filenames with a lowercase first letter. To have the files be sorted alphabetically irrelevant of case, go into the given AttachListSort.php and replace all instances of namelistwitharraymap(′strtolower′,namelist with array_map('strtolower', namelistwitharraymap(strtolower,namelist) .

The filename's capitalization will still be shown in the attachment list - it just won't be used for sorting purposes if you make this change.

Installing

Copy AttachListSort.phpΔ to your cookbook directory

In your config.php enter:

include_once("cookbook/AttachListSort.php");

or in your farmconfig.php enter:

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

Notes

Release Notes

See Also

Contributors

Comments

See discussion at AttachListSort-Talk

User notes +1: 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.