From 077929f8bf8020c8c5445813d6615dbe6a86a818 Mon Sep 17 00:00:00 2001 From: Robbie Averill Date: Fri, 13 Jan 2017 15:55:48 +1300 Subject: [PATCH] Add sidebar back as a separate tab. Fix tag and category routes --- src/Model/BlogCategory.php | 3 +- src/Model/BlogObject.php | 2 +- src/Model/BlogPost.php | 61 +++++++++++++++++++------------------- src/Model/BlogTag.php | 2 +- 4 files changed, 33 insertions(+), 35 deletions(-) diff --git a/src/Model/BlogCategory.php b/src/Model/BlogCategory.php index 28b6dd5..b520360 100644 --- a/src/Model/BlogCategory.php +++ b/src/Model/BlogCategory.php @@ -64,7 +64,7 @@ class BlogCategory extends DataObject implements CategorisationObject */ protected function getListUrlSegment() { - return 'categories'; + return 'category'; } /** @@ -74,5 +74,4 @@ class BlogCategory extends DataObject implements CategorisationObject { return _t('BlogCategory.Duplicate', 'A blog category already exists with that name.'); } - } diff --git a/src/Model/BlogObject.php b/src/Model/BlogObject.php index 2500084..3c0eecd 100644 --- a/src/Model/BlogObject.php +++ b/src/Model/BlogObject.php @@ -211,7 +211,7 @@ trait BlogObject ); if ($this->ID) { - $duplicates->exclude('ID', $this->ID); + $duplicates = $duplicates->exclude('ID', $this->ID); } return $duplicates; diff --git a/src/Model/BlogPost.php b/src/Model/BlogPost.php index 4499502..2abae30 100644 --- a/src/Model/BlogPost.php +++ b/src/Model/BlogPost.php @@ -272,11 +272,6 @@ class BlogPost extends Page ); } - /** - * @todo Fix the sidebar styles for SS4 + Bootstrap - */ - return; - // Get categories and tags $parent = $this->Parent(); $categories = $parent instanceof Blog @@ -286,32 +281,36 @@ class BlogPost extends Page ? $parent->Tags() : BlogTag::get(); - $options = BlogAdminSidebar::create( - $publishDate, - $urlSegment, - TagField::create( - 'Categories', - _t('BlogPost.Categories', 'Categories'), - $categories, - $this->Categories() - ) - ->setCanCreate($this->canCreateCategories()) - ->setShouldLazyLoad(true), - TagField::create( - 'Tags', - _t('BlogPost.Tags', 'Tags'), - $tags, - $this->Tags() - ) - ->setCanCreate($this->canCreateTags()) - ->setShouldLazyLoad(true), - $authorField, - $authorNames - )->setTitle('Post Options'); - - $options->setName('blog-admin-sidebar'); - - $fields->insertBefore($options, 'Root'); + // @todo: Reimplement the sidebar + // $options = BlogAdminSidebar::create( + $fields->addFieldsToTab( + 'Root.PostOptions', + [ + $publishDate, + $urlSegment, + TagField::create( + 'Categories', + _t('BlogPost.Categories', 'Categories'), + $categories, + $this->Categories() + ) + ->setCanCreate($this->canCreateCategories()) + ->setShouldLazyLoad(true), + TagField::create( + 'Tags', + _t('BlogPost.Tags', 'Tags'), + $tags, + $this->Tags() + ) + ->setCanCreate($this->canCreateTags()) + ->setShouldLazyLoad(true), + $authorField, + $authorNames + ] + ); + // )->setTitle('Post Options'); + // $options->setName('blog-admin-sidebar'); + // $fields->insertBefore($options, 'Root'); }); $fields = parent::getCMSFields(); diff --git a/src/Model/BlogTag.php b/src/Model/BlogTag.php index 9e65e1e..fd847c2 100644 --- a/src/Model/BlogTag.php +++ b/src/Model/BlogTag.php @@ -64,7 +64,7 @@ class BlogTag extends DataObject implements CategorisationObject */ protected function getListUrlSegment() { - return 'tags'; + return 'tag'; } /**