PHPackages                             claudejanz/yii2-nested-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. claudejanz/yii2-nested-sortable

ActiveYii2-extension[Utility &amp; Helpers](/categories/utility)

claudejanz/yii2-nested-sortable
===============================

an implementation of nestedSortable2.0

v1.0.2(8y ago)17.9k2BSD-4-ClausePHP

Since Sep 21Pushed 8y ago2 watchersCompare

[ Source](https://github.com/claudejanz/yii2-nested-sortable)[ Packagist](https://packagist.org/packages/claudejanz/yii2-nested-sortable)[ RSS](/packages/claudejanz-yii2-nested-sortable/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (4)Used By (0)

Nested Sortable
===============

[](#nested-sortable)

[![Latest Stable Version](https://camo.githubusercontent.com/a41c17ce4000e9426b0ee91f0ce9e2846c1666f268d288e472bfc265b4a1ff2b/68747470733a2f2f706f7365722e707567782e6f72672f636c617564656a616e7a2f796969322d6e65737465642d736f727461626c652f762f737461626c652e737667)](https://packagist.org/packages/claudejanz/yii2-nested-sortable) [![Total Downloads](https://camo.githubusercontent.com/19589d631bfc5536713bd41e229a3e3c8f69a5707dddca5167ee6cf633b6aeed/68747470733a2f2f706f7365722e707567782e6f72672f636c617564656a616e7a2f796969322d6e65737465642d736f727461626c652f646f776e6c6f6164732e737667)](https://packagist.org/packages/claudejanz/yii2-nested-sortable) [![Latest Unstable Version](https://camo.githubusercontent.com/0024664517dfdb757d1fe6d2ab5cbe81e5db25f83f9704e476efdd0072438ca8/68747470733a2f2f706f7365722e707567782e6f72672f636c617564656a616e7a2f796969322d6e65737465642d736f727461626c652f762f756e737461626c652e737667)](https://packagist.org/packages/claudejanz/yii2-nested-sortable) [![License](https://camo.githubusercontent.com/67942850e6bf6a24a0ba8cc198304a13f9b59fdb28ffb45b3e7b020e6725d636/68747470733a2f2f706f7365722e707567782e6f72672f636c617564656a616e7a2f796969322d6e65737465642d736f727461626c652f6c6963656e73652e737667)](https://packagist.org/packages/claudejanz/yii2-nested-sortable)

an implementation of [nestedSortable2.0](http://ilikenwf.github.io/example.html)

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

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist claudejanz/yii2-nested-sortable "*"

```

or add

```
"claudejanz/yii2-nested-sortable": "*"

```

to the require section of your `composer.json` file.

Prepare Model
-------------

[](#prepare-model)

In table migrateion:

```
$this->createTable('page', [
    'id'               => $this->primaryKey(),
    'title'            => $this->string(255)->notNull(),
    'parent_id'        => $this->integer()->null(),
    'weight'           => $this->integer(11)->notNull()->defaultValue(1),
]);

$this->createIndex('idx-page-parent_id', 'page', 'parent_id');
$this->addForeignKey('fk-page-parent_id-page-id', 'page', 'parent_id', 'page', 'id', 'SET NULL', 'CASCADE');
```

In ActiveRecord: [for more details on Customizing Query Classes](http://www.yiiframework.com/doc-2.0/guide-db-active-record.html#customizing-query-classes)

```
/**
* @inheridoc
*/
public static function find()
{
    return (new PageQuery(get_called_class()))->orderBy('weight');
}

/**
* @return ActiveQuery
*/
public function getParent()
{
   return $this->hasOne(Page::className(), ['id' => 'parent_id']);
}

/**
* @return ActiveQuery
*/
public function getPages()
{
   return $this->hasMany(Page::className(), ['parent_id' => 'id'])->inverseOf('parent');
}
```

Usage
-----

[](#usage)

Once the extension is installed, simply use it in your code by :

In view:

```
use claudejanz\yii2nestedSortable\NestedSortable;
echo NestedSortable::widget([
    'items'         => Page::find()->andWhere(['parent_id'=>null])->all(),
    'url'           => ['pages/save-sortable'],
    'contentAttribute' => 'title';
    'itemsAttribute' => 'pages';
]);
```

In controller:

```
public function actions()
{
    return [
        'save-sortable' => [
            'class' => 'claudejanz\yii2nestedSortable\NestedSortableAction',
            //'scenario'=>'editable',  //optional
            'modelclass' => Page::className(),
        ],
    ];
}
```

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity65

Established project with proven stability

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 ~217 days

Total

3

Last Release

3084d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1180289?v=4)[Claude JANZ](/maintainers/claudejanz)[@claudejanz](https://github.com/claudejanz)

---

Tags

yii2extensionnestedSortable2.0

### Embed Badge

![Health badge](/badges/claudejanz-yii2-nested-sortable/health.svg)

```
[![Health](https://phpackages.com/badges/claudejanz-yii2-nested-sortable/health.svg)](https://phpackages.com/packages/claudejanz-yii2-nested-sortable)
```

###  Alternatives

[richardfan1126/yii2-sortable-gridview

Sortable GridView for Yii2

29189.3k](/packages/richardfan1126-yii2-sortable-gridview)[sjaakp/yii2-taggable

Manage tags of ActiveRecord in Yii2.

3030.6k](/packages/sjaakp-yii2-taggable)[dmstr/yii2-cookie-consent

Yii2 Cookie Consent Widget

1452.6k](/packages/dmstr-yii2-cookie-consent)

PHPackages © 2026

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