22 votes

Document Sorter

SUMMARY

This package automaticaly sorts nodes in either Alphabetical, Numerical or Date order.

This package is ideal for things like news sections where you want documents to appear in date order, or a-z style pages where you want documents automcatialy sorted by name.

HOW TO USE

The package is configured via a documentSorter.config file located in the default umbraco config folder.

To define a new sort rule, create an add element with the following attributes.

  • docTypeAlias [Optional] - The doc type alias of the documents to be sorted, if undefined, applies to all
  • field - The field name to sort on. You can also sort on the following reserved fields - id, nodeName, createDate, updateDate. Each reseved field will automaticaly override the type attribute with its respective data type.
  • type - Must be either Alpha, Numeric or Date. Numeric fields must currently be of type int.
  • order - Must be either Asc or Desc. Sorts the list in either ascending or descending order.
  • rootXpath [Optional] - An xpath statment to define the root folder for the sort rule, ie: //newsIndex[@isDoc]  (4.5 schema)  or  //node[@nodeTypeAlias='newsIndex']  (4.0 schema)
  • disableTreeRefresh [Optional] - in some cases other 3rd party plugins may refresh the tree and can cause the tree to collapse if Document Sorter also refreshes it.  In this case you can set this to true to cause the tree not to be refreshed by Document Sorter.

After creating your sort rule, touch the web.config file to make it active.  The sorting happens each time you Save or Create a document that matches your rules.

UPDATES

1.0.2  - Made docTypeAlias optional so you can sort multiple types. If you don't define docTypeAlias, it is advised you define rootXpath to narrow down the scope of the sort.

1.0.3 - Fixed issue when publishing root node.

1.2.0 - Umbraco v4.5+ compatible & now sorts on create aswell as save and save and publish

1.3.0 - Tree now refreshes automatically after sorting (can be disabled).  Couple small bugfixes concerning Scheduled Publishing and Numeric sorting on custom fields.  Tested with Umbraco v4.7.1.

2.0.0 beta - Umbraco v6.1.2+ compatible and fully refactored to use v6 API instead of v4

2.0.2 beta - Umbraco v6.1.3+ compatible and bug fixes plus switch to using ContentService.Sort method

BUGS & ISSUES

Sorting documents is inherantly a database intensive process. If you are sorting a LOT of documents, this package may not be the best solution.

Please raise any issues on the forum below. All feedback is welcome and appreciated.

Project owner

Matt Brailsford

Matt Brailsford

Matt has 9216 karma points

Project Compatibility

This project is compatible with the following versions as reported by community members who have downloaded this package:
Untested or doesn't work on Umbraco Cloud
7.10.x (untested)
7.9.x (untested)
7.8.x (untested)
7.7.x (untested)
7.6.x (untested)
7.5.x (untested)
7.4.x (untested)
7.3.x (100%)
7.2.x (untested)
7.1.x (untested)
7.0.x (untested)
6.1.x (untested)
6.0.x (untested)

You must login before you can report on package compatibility.

Project Information

  • Project owner: Matt Brailsford
  • Contributors: Tom Fulton , Jeavon Leopold
  • Created: 11/05/2010
  • Current version 1.3.0
  • License MIT
  • Downloads: 3502

External resources