From 68a00986ecf5a8a1823370f3424cbe636aeb5151 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Thu, 20 Jun 2019 15:34:12 +0200 Subject: [PATCH] #2843 --- composer.json | 1 - src/app/Magic/BunchOfFields.php | 6 ++++ src/app/Magic/Models/CMSPage.php | 49 ++++++++++++++++++++++++++++++-- 3 files changed, 53 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index ee97085..ea26ef5 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,6 @@ "backpack/logmanager": "^2.3", "backpack/menucrud": "^1.0", "backpack/newscrud": "^2.1", - "backpack/pagemanager": "^1.1", "backpack/permissionmanager": "^4.0", "backpack/settings": "^2.1", "backpack/langfilemanager": "^1.0", diff --git a/src/app/Magic/BunchOfFields.php b/src/app/Magic/BunchOfFields.php index c4992ff..e042208 100644 --- a/src/app/Magic/BunchOfFields.php +++ b/src/app/Magic/BunchOfFields.php @@ -26,6 +26,12 @@ trait BunchOfFields return $field; } + public function addFakeField(array $attributes) + { + $attributes['fake'] = true; + return $this->addField($attributes); + } + /** * @return Field[] */ diff --git a/src/app/Magic/Models/CMSPage.php b/src/app/Magic/Models/CMSPage.php index 5482ee8..7f60120 100644 --- a/src/app/Magic/Models/CMSPage.php +++ b/src/app/Magic/Models/CMSPage.php @@ -5,6 +5,8 @@ namespace Cubist\Backpack\app\Magic\Models; class CMSPage extends CubistMagicModel { + protected static $_templates = []; + protected $table = 'cms_pages'; protected $_options = ['name' => 'page', @@ -20,7 +22,7 @@ class CMSPage extends CubistMagicModel 'label' => 'Template', 'options' => $this->getTemplates(), 'column' => true, - 'tab'=>'General', + 'tab' => 'General', ]); $this->addField(['name' => 'name', @@ -28,7 +30,7 @@ class CMSPage extends CubistMagicModel 'type' => 'Text', 'column' => true, 'hint' => trans('for admin use'), - 'tab'=>'General', + 'tab' => 'General', ]); $this->addField(['name' => 'title', @@ -40,6 +42,49 @@ class CMSPage extends CubistMagicModel 'type' => 'Slug', 'label' => 'Slug (URL)' ]); + + $this->_common(); + } + + protected function _common() + { + $this->addFakeField([ + 'name' => 'status', + 'type' => 'SelectFromArray', + 'default' => '0', + 'label' => __('Status'), + 'options' => ['0' => __('Offline'), '1' => __('Published')], + 'tab' => 'Général', + ]); + $this->_seo(); + } + + protected function _seo() + { + $this->addFakeField([ + 'name' => 'meta_title', + 'label' => trans('backpack::pagemanager.meta_title'), + 'type' => 'Text', + 'hint' => trans('If empty, page title is used.') . ' ' . __('Recommended length: 60 chars'), + 'tab' => 'Meta // SEO', + 'store_in'=>'seo', + ]); + $this->addFakeField([ + 'name' => 'meta_description', + 'label' => trans('backpack::pagemanager.meta_description'), + 'type' => 'Textarea', + 'hint' => __('Recommended length: 160 chars'), + 'tab' => 'Meta // SEO', + 'store_in'=>'seo', + ]); + $this->addFakeField([ + 'name' => 'robots', + 'label' => __('Allow page index by search engines'), + 'type' => 'Checkbox', + 'default' => true, + 'tab' => 'Meta // SEO', + 'store_in'=>'seo', + ]); } public function getTemplates($template_name = false) -- 2.39.5