Custom columns in folder lists
Show fields from the documents in a folder as extra columns in the Docly folder view, and sort the folder by one of them — ascending, descending or by drag and drop. The columns are set in the folder's properties and only affect the folder view in Docly, not the published site.
Set up columns
Right-click the folder and choose Properties.
On the General tab, check the Folder type. The built-in types Folder, Published folder and Docly Workspace (a workspace root) have the column settings. For another type, click Change … and pick one of them, or add the fields to your own folder schema (see below).
Open the Properties tab and tick Specify custom columns.
Add a row per column: Title, Column / formula and Sort list by.
Optionally tick Hide the default filename column when your columns already identify each row.
Save. The folder view shows the columns the next time it loads.
See Changing folder schema and properties for the dialog itself.
Column / formula
The formula is a field name, optionally wrapped in one conversion. It is not a JavaScript expression: Price * 2 or Address.City look for a field with that literal name and show nothing.
Formula | Shows |
|---|---|
| The document's |
| The field as a whole number; text that is not a number becomes 0 |
| The field as a decimal number. |
| The field as a date |
| A 60 × 60 thumbnail of the image in that field |
| A 30 × 30 thumbnail |
| The document name (display only — it cannot sort the folder) |
Conversion names are case-insensitive. An unknown name in front of the parentheses is ignored, and the field is shown as text.
parseInt/cintnever fail.parseFloat,cdec,cdbl,clngandcdatedo: a non-empty value they cannot convert makes the folder view report an error instead of showing the folder. Use them only on fields that always hold a valid number or date.An empty formula uses the Title as the field name.
Only top-level fields are read. A field inside a chapter array or a nested object cannot be shown.
An empty field shows an empty cell. Values are shown as text — HTML in a field is not rendered.
For a subfolder, the values come from its properties document, so subfolders can take part when their folder schema has the same field.
Sort list by
Value | Effect |
|---|---|
No | A plain column. The folder is not sorted by it. |
Ascending | The folder is listed by this column, lowest value first. |
Descending | Highest value first. |
Sortable | Ascending, and rows can be dragged into a new order. |
Only the first column with a sort setting counts. Columns further down with Ascending, Descending or Sortable are ignored, and drag-and-drop is on only when that first sorting column is Sortable.
Sort numbers with a conversion. Without one the values compare as text, case-insensitively, so 10 comes before 2. Use
parseInt(Order).Documents without the field come first in ascending order, and last in descending.
Documents and subfolders are sorted together when the folder is sorted, instead of folders first.
In a locked folder the sorting is not applied.
Drag-and-drop ordering
With a Sortable column, drag a row by its icon and drop it where it belongs. Docly then numbers every item in the folder 1, 2, 3 … in the new order and writes that number into the field the formula names — Order for parseInt(Order) — saving each document. For a subfolder it writes the folder's properties document; a subfolder without one is skipped.
You need edit access to the folder and its documents.
Every drag saves every document in the folder: hand-set gaps such as 10, 20, 30 are gone after the first drag, the modified date changes on all of them, and a schema with versioning gets a new version of each.
The documents' schema should have the field, as a number field. Documents that lack it simply get it on the first drag.
The stored properties
The settings live in the folder's properties document (the .docly file inside the folder). Docly reads only Title, Formula and Sorting from each row:
{
"SpecifyCustomColumns": true,
"CustomColumns": [
{ "Title": "Category", "Formula": "Category", "Sorting": "No" },
{ "Title": "Order", "Formula": "parseInt(Order)", "Sorting": "Sortable" }
],
"CustomColumns_type": "CustomColumns",
"HideFilenameColumn": false
} Docly reads CustomColumns from the properties document whatever its folder schema is. To offer the setting in your own folder schema, give it a table named CustomColumns with the fields Title, Formula and Sorting (No, Ascending, Descending, Sortable), and a check box HideFilenameColumn. To remove the columns, delete the rows.
On small screens
On a phone-width screen the custom columns are hidden and the name column is shown. With Hide the default filename column ticked, the first custom column takes the name column's place and stays visible.
The published site has its own order
The columns and the sort order belong to the Docly folder view. A page that lists the documents decides its own order — sort by the same field, as a number:
#for (let item of docly.sort(docly.getFiles("faq"), "Order", "parseInt")) {#
<h3>#docly.htmlEncode(item.Title)#</h3>
#}# Full walkthrough: Sort folder contents by a custom field. For thumbnails in the folder view without a column, see Preview image in folder lists.