2017 © Pedro Peláez
 

silverstripe-module silverstripe-dropzone-sortable

A Silverstripe extension to add drag/drop sorting to FileAttachmentField

image

webfox/silverstripe-dropzone-sortable

A Silverstripe extension to add drag/drop sorting to FileAttachmentField

  • Monday, January 25, 2016
  • by webfox
  • Repository
  • 3 Watchers
  • 2 Stars
  • 39 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 4 Forks
  • 3 Open issues
  • 4 Versions
  • 5 % Grown

The README.md

Note:

Currently waiting on a pull request merge https://github.com/unclecheese/silverstripe-dropzone/pull/34 before this is
functional. Until this is merged if you would like to use this module then use the fork this pull request references., (*1)

Silverstripe Dropzone Sortable

This plugin allows drag/drop sorting via FileAttachmentField from the dropzone package., (*2)

Installation Instructions

Composer

Run the following to add this module as a requirement and install it via composer., (*3)

composer require "webfox/silverstripe-dropzone-sortable"

Setup

Setting up the Relation

We need a SortOrder column on the Image/File relation that FileAttachmentField is hooked onto.
For a has_many to a custom DataObject simply add the 'SortOrder' => 'int' and private static $default_sort = 'SortOrder'; to the DataObject., (*4)

If you are relating to Image or File directly then you will need a many_many setup with many_many_extrafields and an accessor to loop over in the template
<% loop $SortedImages>...<% end_loop %> or you can do <% loop $Images.Sort('SortOrder') %>...<% end_loop %>. This package will automatically sort the files in the FileAttachmentField., (*5)

Here is an example many_many setup:, (*6)

class MyPage extends Page {

    private static $many_many = [
        'Images' => 'Image'
    ];

    private static $many_many_extraFields = [
        'Images' => ['SortOrder' => 'Int']
    ];

    public function getSortedImages(){
        return $this->Images()->sort('SortOrder');
    }
}

Enabling Sorting

To enable sorting simply call ->sortable() on the FileAttachmentField e.g. FileAttachmentField::create('Images')->sortable()->imagesOnly();, (*7)

Customization

The only customization available is changing the sort column. FileAttachmentField::create('Images')->sortable()->setSortableColumn('OtherSortColumn');, (*8)

The Versions

25/01 2016

dev-master

9999999-dev

A Silverstripe extension to add drag/drop sorting to FileAttachmentField

  Sources   Download

MIT

The Requires

 

by Matthew Hailwood

silverstripe sortable dropzone webfox

25/01 2016

v1.0.2

1.0.2.0

A Silverstripe extension to add drag/drop sorting to FileAttachmentField

  Sources   Download

MIT

The Requires

 

by Matthew Hailwood

silverstripe sortable dropzone webfox

25/11 2015

v1.0.1

1.0.1.0

A Silverstripe extension to add drag/drop sorting to FileAttachmentField

  Sources   Download

MIT

The Requires

 

by Matthew Hailwood

silverstripe sortable dropzone webfox

25/11 2015

v1.0.0

1.0.0.0

A Silverstripe extension to add drag/drop sorting to FileAttachmentField

  Sources   Download

MIT

The Requires

 

by Matthew Hailwood

silverstripe sortable dropzone webfox