From 349851dd11e7df344664e53e1cf66e49f6735ab5 Mon Sep 17 00:00:00 2001 From: Samuel Georges Date: Fri, 28 Apr 2017 23:37:50 +1000 Subject: [PATCH] Partials, pages and content now support drag'n'drop --- modules/cms/widgets/TemplateList.php | 22 +++++++++++++++++-- .../widgets/templatelist/partials/_items.htm | 4 +++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/modules/cms/widgets/TemplateList.php b/modules/cms/widgets/TemplateList.php index 52fd243a5..035194190 100644 --- a/modules/cms/widgets/TemplateList.php +++ b/modules/cms/widgets/TemplateList.php @@ -300,16 +300,34 @@ class TemplateList extends WidgetBase 'title' => $this->getItemTitle($item), 'fileName' => $item->getFileName(), 'description' => $description, - 'descriptions' => $descriptions + 'descriptions' => $descriptions, + 'dragValue' => $this->getItemDragValue($item) ]; - foreach ($this->sortingProperties as $property=>$name) { + foreach ($this->sortingProperties as $property => $name) { $result[$property] = $item->$property; } return (object) $result; } + protected function getItemDragValue($item) + { + if ($item instanceof \Cms\Classes\Partial) { + return "{% partial '".$item->getBaseFileName()."' %}"; + } + + if ($item instanceof \Cms\Classes\Content) { + return "{% content '".$item->getBaseFileName()."' %}"; + } + + if ($item instanceof \Cms\Classes\Page) { + return "{{ '".$item->getBaseFileName()."'|page }}"; + } + + return ''; + } + protected function getItemTitle($item) { $titleProperty = $this->titleProperty; diff --git a/modules/cms/widgets/templatelist/partials/_items.htm b/modules/cms/widgets/templatelist/partials/_items.htm index 88f9a32d6..852c26ee8 100644 --- a/modules/cms/widgets/templatelist/partials/_items.htm +++ b/modules/cms/widgets/templatelist/partials/_items.htm @@ -18,7 +18,9 @@ data-item-theme="theme->getDirName()) ?>" data-item-type="itemType ?>" data-id=""> - + title) ?> descriptions as $title => $value): ?>