{"id":40944375,"url":"https://github.com/oppara/cakephp-plugin-sortable","last_synced_at":"2026-01-22T04:38:45.082Z","repository":{"id":57032474,"uuid":"114549846","full_name":"oppara/cakephp-plugin-sortable","owner":"oppara","description":"CakePHP plugin that mainly for jQuery UI Sortable ","archived":false,"fork":false,"pushed_at":"2018-02-16T01:03:47.000Z","size":12,"stargazers_count":1,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-10-11T22:23:04.244Z","etag":null,"topics":["cakephp3","plugin"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oppara.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-17T16:04:35.000Z","updated_at":"2018-05-25T12:25:14.000Z","dependencies_parsed_at":"2022-08-23T20:50:22.782Z","dependency_job_id":null,"html_url":"https://github.com/oppara/cakephp-plugin-sortable","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/oppara/cakephp-plugin-sortable","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oppara%2Fcakephp-plugin-sortable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oppara%2Fcakephp-plugin-sortable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oppara%2Fcakephp-plugin-sortable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oppara%2Fcakephp-plugin-sortable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oppara","download_url":"https://codeload.github.com/oppara/cakephp-plugin-sortable/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oppara%2Fcakephp-plugin-sortable/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28654987,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-22T01:17:37.254Z","status":"online","status_checked_at":"2026-01-22T02:00:07.137Z","response_time":144,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cakephp3","plugin"],"created_at":"2026-01-22T04:38:45.024Z","updated_at":"2026-01-22T04:38:45.073Z","avatar_url":"https://github.com/oppara.png","language":"PHP","readme":"# CakePHP plugin that mainly for [jQuery UI Sortable](https://jqueryui.com/sortable/)\n\n[![Build Status](https://travis-ci.org/oppara/cakephp-plugin-sortable.svg?branch=master)](https://travis-ci.org/oppara/cakephp-plugin-sortable)\n[![codecov](https://codecov.io/gh/oppara/cakephp-plugin-sortable/branch/master/graph/badge.svg)](https://codecov.io/gh/oppara/cakephp-plugin-sortable)\n\n## Installation\n\n```\ncomposer require oppara/cakephp-plugin-sortable\n```\n\n## Enable plugin\n\n\n```php\n// config/bootstrap.php\n\u003c?php\nPlugin::load('Sortable');\n```\n\nor\n\n```php\n// config/bootstrap.php\n\u003c?php\nPlugin::loadAll();\n```\n\n\n## Examples\n\n```sql\nCREATE TABLE articles (\n    id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,\n    user_id INT UNSIGNED NOT NULL,\n    display_order SMALLINT UNSIGNED NOT NULL DEFAULT 0,\n    title VARCHAR(255) NOT NULL,\n    body TEXT,\n    created DATETIME,\n    modified DATETIME\n);\n```\n\n```php\n// src/Model/Table/ArticlesTable.php\nnamespace App\\Model\\Table;\n\nuse Cake\\ORM\\Table;\n\nclass ArticlesTable extends Tabl\n{\n    public function initialize(array $config)\n    {\n        $this-\u003eaddBehavior('Sortable.Sortable', [\n            'condition_fields' =\u003e ['user_id']\n        ]);\n    }\n\n```\n\n```php\n//  src/Controller/ArticlesController.php\nclass ArticlesController extends AppController\n{\n\n    public function sort()\n    {\n        if (!$this-\u003erequest-\u003eis('ajax')) {\n            exit;\n        }\n\n        $data = json_encode($this-\u003erequest-\u003egetData());\n        $this-\u003elog(__METHOD__ . ' data:' . $data, LOG_DEBUG);\n\n        $id = $this-\u003erequest-\u003egetData('id');\n        $new_order = $this-\u003erequest-\u003egetData('display_order');\n        $this-\u003eSections-\u003esort($id, $new_order);\n\n        return $this-\u003eresponse-\u003ewithType('application/json')\n            -\u003ewithStringBody(json_encode(['status' =\u003e 'OK']));\n    }\n\n```\n\n```php\n//  src/Template/Articles/index.ctp\n\n$this-\u003eHtml-\u003ecss(['sort'], ['block' =\u003e true]);\n$this-\u003eHtml-\u003escript(['jquery-ui.min', 'sort'], ['block' =\u003e true]);\n\n\u003cdiv class=\"row\"\u003e\n  \u003cdiv class=\"col-md-12\"\u003e\n    \u003ctable cellpadding=\"0\" cellspacing=\"0\" class=\"table table-hover table-bordered sortable\"\u003e\n        \u003cthead\u003e\n            \u003ctr\u003e\n                \u003cth class=\"col-md-8\" scope=\"col\"\u003etitle\u003c/th\u003e\n                \u003cth class=\"col-md-4\" scope=\"col\" class=\"actions\"\u003eActions\u003c/th\u003e\n            \u003c/tr\u003e\n        \u003c/thead\u003e\n        \u003ctbody\u003e\n            \u003c?php foreach ($articles as $article): ?\u003e\n            \u003ctr data-id=\"\u003c?= $article-\u003eid ?\u003e\" data-url=\"\u003c?= Router::url(['controller' =\u003e 'articles', 'action' =\u003e 'sort']) ?\u003e\"\u003e\n                \u003ctd class=\"handle\"\u003e\u003c?= h($article-\u003etitle) ?\u003e\u003c/td\u003e\n                \u003ctd class=\"actions\"\u003e\n                    \u003c?= $this-\u003eHtml-\u003elink('View', ['action' =\u003e 'view', $article-\u003eid], ['class' =\u003e 'btn btn-info btn-sm']) ?\u003e\n                    \u003c?= $this-\u003eHtml-\u003elink('Edit', ['action' =\u003e 'edit', $article-\u003eid], ['class' =\u003e 'btn btn-info btn-sm']) ?\u003e\n                \u003c/td\u003e\n            \u003c/tr\u003e\n            \u003c?php endforeach; ?\u003e\n        \u003c/tbody\u003e\n    \u003c/table\u003e\n  \u003c/div\u003e\n\u003c/div\u003e\n```\n\n```javascript\n// src/webroot/sort.js\n$(function(){\n\n  $('.sortable').sortable({\n    items: 'tbody tr:not(.ui-sort-disabled)',\n    axis: 'y',\n    placeholder: 'ui-state-highlight',\n    cursor: 'row-resize',\n    handle: '.handle',\n    opacity: 0.5,\n\n    start: function(e, ui) {\n      var tableWidth = $(this).width(),\n        cells = ui.item.children('td'),\n        widthForEachCell = tableWidth / cells.length + 'px';\n\n      cells.css('width', widthForEachCell);\n    },\n\n    update: function(e, ui) {\n      var item = ui.item,\n        item_data = item.data();\n\n      var params = {\n        id: item_data.id,\n        display_order: item.index()\n      };\n\n      $.ajax({\n        type: 'POST',\n        url: item_data.url,\n        dataType: 'json',\n        data: params,\n        cache: false\n      }).fail(function() {\n        alert ('ERROR!');\n      });\n    }\n  });\n\n});\n```\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foppara%2Fcakephp-plugin-sortable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foppara%2Fcakephp-plugin-sortable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foppara%2Fcakephp-plugin-sortable/lists"}