PHPackages                             fromholdio/silverstripe-sortable - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. fromholdio/silverstripe-sortable

ActiveSilverstripe-vendormodule[Utility &amp; Helpers](/categories/utility)

fromholdio/silverstripe-sortable
================================

Adds an extension to make any SilverStripe DataObject sortable.

4.0.0(8mo ago)11.5k12BSD-3-ClausePHP

Since Feb 18Pushed 1w ago1 watchersCompare

[ Source](https://github.com/fromholdio/silverstripe-sortable)[ Packagist](https://packagist.org/packages/fromholdio/silverstripe-sortable)[ Docs](https://github.com/fromholdio/silverstripe-sortable)[ RSS](/packages/fromholdio-silverstripe-sortable/feed)WikiDiscussions master Synced 6d ago

READMEChangelog (5)Dependencies (1)Versions (12)Used By (2)

silverstripe-sortable
=====================

[](#silverstripe-sortable)

Adds an extension to make any SilverStripe DataObject sortable.

That is, it does the basic lifting of:

- Adding a `Sort` field of type `DBInt` to your object
- Removing the scaffolded field from CMS fields
- Sets the `$default_sort` of your object to `'Sort'`
- Manages setting a `Sort` value of the maximum + 1 upon first write, within a scope you define

Versioning
----------

[](#versioning)

Through a bit of bungling, v1.1.1 and v2.1.1 are equal. For clarity, moving forward only 2.x will receive any necessary patches/fixes.

Return types have been added, and a new major version track has been established as v3.x. As such this will require PHP &gt;=7.0, is now the primary track, and will receive any enhancements/features in future.

Requirements
------------

[](#requirements)

SilverStripe 4 or 5

Installation
------------

[](#installation)

`composer require fromholdio/silverstripe-sortable`

Details
-------

[](#details)

It's all plug-n-play once you apply the extension to your data object - with one exception.

To allow the extension to auto-generate a default value, based on maximum + 1, you need to tell the extension what the scope of the group you're getting that maximum value from is.

So, on the object you are extending/applying `Sortable` to, you can add a `getSortableScope()` method. This method should return a `DataList` on which sortable will run `->max('Sort')` on.

In the absence of a `getSortableScope()` method, as a fallback the extension will get all objects of this type, excluding the current object, and run `->max('Sort')` on this list.

See below for example.

Usage example
-------------

[](#usage-example)

We are applying `Sortable` to a `Widget` data object:

```
class Widget extends DataObject
{
    // or apply via config.yml
    private static $extensions = [
        Sortable::class
    ];

    public function getSortableScope()
    {
        # this is the default behaviour
        return self::get()->exclude('ID', $this->ID);
    }
}
```

That's it! And it assumes that Widgets will be sorted amongst each other globally.

If Widgets had a one-many relationship with pages, and we want to sort them -per page- then we could do the following instead:

```
class Widget extends DataObject
{
    private static $has_one = [
        'Page' => \Page::class  // (assuming a has_many on Page for Widgets)
    ];

    // or apply via config.yml
    private static $extensions = [
        Sortable::class
    ];

    public function getSortableScope()
    {
        return self::get()
            ->filter('PageID', $this->PageID)
            ->exclude('ID', $this->ID);
    }
}
```

Depending on your data model structures, the ability to pass a scope DataList can be pretty useful. Have fun!

###  Health Score

49

—

FairBetter than 95% of packages

Maintenance82

Actively maintained with recent releases

Popularity20

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 92.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~267 days

Recently: every ~353 days

Total

10

Last Release

241d ago

Major Versions

1.0.0 → 2.0.02021-07-16

1.1.0 → 2.1.12021-11-04

1.1.1 → 3.0.02022-05-11

3.x-dev → 4.0.02025-09-19

PHP version history (2 changes)1.0.0PHP &gt;=5.6

3.0.0PHP &gt;=7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/40e135ad117686bee39707c1d9286cc5e915e219c26a10d13858ca44d14f1eb0?d=identicon)[dizzystuff](/maintainers/dizzystuff)

---

Top Contributors

[![dizzystuff](https://avatars.githubusercontent.com/u/576903?v=4)](https://github.com/dizzystuff "dizzystuff (12 commits)")[![xini](https://avatars.githubusercontent.com/u/1152403?v=4)](https://github.com/xini "xini (1 commits)")

---

Tags

silverstripesortablesortdataobjectorderable

### Embed Badge

![Health badge](/badges/fromholdio-silverstripe-sortable/health.svg)

```
[![Health](https://phpackages.com/badges/fromholdio-silverstripe-sortable/health.svg)](https://phpackages.com/packages/fromholdio-silverstripe-sortable)
```

###  Alternatives

[symbiote/silverstripe-gridfieldextensions

A collection of useful grid field components

971.8M235](/packages/symbiote-silverstripe-gridfieldextensions)[undefinedoffset/sortablegridfield

Adds drag and drop functionality to Silverstripe's GridField

941.2M50](/packages/undefinedoffset-sortablegridfield)[kyslik/column-sortable

Package for handling column sorting in Laravel 6.x

6485.6M21](/packages/kyslik-column-sortable)[silvershop/silverstripe-listsorter

Easily provide front-end sorting controls for SilverStripe lists

1640.8k4](/packages/silvershop-silverstripe-listsorter)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
