Skip to content

Commit e7726b4

Browse files
Merge pull request #20 from tsanchev/master
add option for start position
2 parents e74effb + 20284e0 commit e7726b4

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public function actions(){
3535
'class' => SortableAction::className(),
3636
'activeRecordClassName' => YourActiveRecordClass::className(),
3737
'orderColumn' => 'name_of_field_storing_ordering',
38+
'startPosition' => 1, // optional, default is 0
3839
],
3940
// your other actions
4041
];

SortableAction.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use yii\base\InvalidConfigException;
88

99
class SortableAction extends Action {
10+
1011
/**
1112
* (required) The ActiveRecord Class name
1213
*
@@ -21,6 +22,13 @@ class SortableAction extends Action {
2122
*/
2223
public $orderColumn;
2324

25+
/**
26+
* Start index/position default 0
27+
*
28+
* @var integer
29+
*/
30+
public $startPosition = 0;
31+
2432
public function init(){
2533
parent::init();
2634
if(!isset($this->activeRecordClassName)){
@@ -41,7 +49,7 @@ public function run(){
4149
$page = $activeRecordClassName::findOne($item);
4250
//$page = $activeRecordClassName::find()->where($item);
4351
$page->updateAttributes([
44-
$this->orderColumn => $i,
52+
$this->orderColumn => $i + $this->startPosition,
4553
]);
4654
}
4755
}

0 commit comments

Comments
 (0)