+++ /dev/null
-<?php
-
-
-namespace Cubist\Backpack\app\Magic\Models;
-
-
-class CMSMenu extends CubistMagicNestedModel
-{
- protected $table = 'cubist_menu';
- protected $_options = ['name' => 'menu',
- 'singular' => 'élément de menu',
- 'plural' => 'éléments de menu'];
-
- public function setFields()
- {
- parent::setFields();
-
- $this->addField(['name' => 'name',
- 'label' => 'Label de la page dans la navigation',
- 'type' => 'Text',
- 'column' => true]
- );
- $this->addField(['name' => 'type',
- 'label' => 'Type de page',
- 'type' => 'SelectFromArray',
- 'options' => ['page_link' => 'Page du site', 'link' => 'Lien externe'],
- 'column' => true]);
-
- $this->addField(['name' => 'page_id',
- 'type' => 'SelectFromModel',
- 'label' => 'Page du site',
- 'optionsmodel' => 'App\Models\Page']);
-
- $this->addField(['name' => 'link',
- 'type' => 'URL',
- 'label' => 'Lien externe']);
- }
-}
use Cubist\Backpack\app\Magic\Controllers\CubistMagicController;
use Cubist\Backpack\app\Template\TemplateAbstract;
-class CMSPage extends CubistMagicModel
+class CMSPage extends CubistMagicNestedModel
{
protected static $_templates = [];
'translatable' => true,
'tab' => 'Informations principales',
]);
- $this->_seo();
- }
-
- protected function _seo()
- {
- $this->addField(['name' => 'slug',
- 'type' => 'Slug',
- 'label' => 'Slug (URL)',
- 'tab' => 'SEO // Meta',
- ]);
-
- $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' => 'SEO // Meta',
- 'store_in' => 'seo',
- ]);
-
- $this->addFakeField([
- 'name' => 'meta_description',
- 'label' => trans('backpack::pagemanager.meta_description'),
- 'type' => 'Textarea',
- 'hint' => __('Recommended length: 160 chars'),
- 'tab' => 'SEO // Meta',
- 'store_in' => 'seo',
- ]);
-
- $this->addFakeField([
- 'name' => 'robots',
- 'label' => __('Allow page index by search engines'),
- 'type' => 'Checkbox',
- 'default' => true,
- 'tab' => 'SEO // Meta',
- 'store_in' => 'seo',
- ]);
}
/**
--- /dev/null
+<?php
+
+
+namespace Cubist\Backpack\app\Template;
+
+
+class Navigation extends TemplateAbstract
+{
+ public function init()
+ {
+ parent::init();
+ $this->addField(['name' => 'navigation',
+ 'type' => 'Text',
+ 'label' => 'Partie du site',
+ 'store_in' => 'nav',
+ 'translatable' => false]
+ );
+ }
+}
--- /dev/null
+<?php
+
+
+namespace Cubist\Backpack\app\Template;
+
+
+class Redirection extends TemplateAbstract
+{
+ public function init()
+ {
+ parent::init();
+ }
+}
}
+
/**
* @param $attributes array
*/
public static function getTemplates()
{
if (null === self::$_templates) {
- $templates_root = app_path() . '/Templates';
- $dr = opendir($templates_root);
- while ($file = readdir($dr)) {
- if ($file == '.' || $file == '..' || is_dir($templates_root . '/' . $file)) {
- continue;
+// self::$_templates=[];
+ $roots = [__DIR__, app_path() . '/Templates'];
+ foreach ($roots as $templates_root) {
+ $dr = opendir($templates_root);
+ while ($file = readdir($dr)) {
+ if ($file == '.' || $file == '..' || is_dir($templates_root . '/' . $file)) {
+ continue;
+ }
+ $e = explode('.', $file);
+ $classname = '\\App\\Templates\\' . $e[0];
+ if (is_subclass_of($classname, 'Cubist\Backpack\app\Template\TemplatePage') || is_subclass_of($classname, 'Cubist\Backpack\app\Template\Navigation')) {
+ die($classname);
+
+ self::$_templates[Str::snake($e[0])] = new $classname();;
+ }
}
- $e = explode('.', $file);
- $classname = '\\App\\Templates\\' . $e[0];
- self::$_templates[Str::snake($e[0])] = new $classname();
}
-
if (!count(self::$_templates)) {
abort(503, trans('backpack::pagemanager.template_not_found'));
}
--- /dev/null
+<?php
+
+
+namespace Cubist\Backpack\app\Template;
+
+class TemplatePage extends TemplateAbstract
+{
+ public function init()
+ {
+ parent::init();
+ $this->_seo();
+ }
+
+ protected function _seo()
+ {
+ $this->addField(['name' => 'slug',
+ 'type' => 'Slug',
+ 'label' => 'Slug (URL)',
+ 'tab' => 'SEO // Meta',
+ ]);
+
+ $this->addField([
+ 'name' => 'meta_title',
+ 'label' => trans('backpack::pagemanager.meta_title'),
+ 'type' => 'Text',
+ 'hint' => trans('If empty, page title is used.') . ' ' . __('Recommended length: 60 chars'),
+ 'tab' => 'SEO // Meta',
+ 'store_in' => 'seo',
+ ]);
+
+ $this->addField([
+ 'name' => 'meta_description',
+ 'label' => trans('backpack::pagemanager.meta_description'),
+ 'type' => 'Textarea',
+ 'hint' => __('Recommended length: 160 chars'),
+ 'tab' => 'SEO // Meta',
+ 'store_in' => 'seo',
+ ]);
+
+ $this->addField([
+ 'name' => 'robots',
+ 'label' => __('Allow page index by search engines'),
+ 'type' => 'Checkbox',
+ 'default' => true,
+ 'tab' => 'SEO // Meta',
+ 'store_in' => 'seo',
+ ]);
+ }
+}