PHP code example of fromholdio / silverstripe-sortable
1. Go to this page and download the library: Download fromholdio/silverstripe-sortable library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
fromholdio / silverstripe-sortable example snippets
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);
}
}
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);
}
}