]> _ Git - pmi.git/commitdiff
wip #2562 @2
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 19 Feb 2019 14:44:29 +0000 (15:44 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 19 Feb 2019 14:44:29 +0000 (15:44 +0100)
app/Http/Controllers/PageController.php [new file with mode: 0644]
app/PageTemplates.php
resources/views/pages/about_us.blade.php [new file with mode: 0644]
resources/views/pages/services.blade.php [new file with mode: 0644]
routes/web.php

diff --git a/app/Http/Controllers/PageController.php b/app/Http/Controllers/PageController.php
new file mode 100644 (file)
index 0000000..42943dd
--- /dev/null
@@ -0,0 +1,24 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use Backpack\PageManager\app\Models\Page;
+use App\Http\Controllers\Controller;
+
+class PageController extends Controller
+{
+    public function index($slug)
+    {
+        $page = Page::findBySlug($slug);
+
+        if (!$page)
+        {
+            abort(404, 'Please go back to our <a href="'.url('').'">homepage</a>.');
+        }
+
+        $this->data['title'] = $page->title;
+        $this->data['page'] = $page->withFakes();
+
+        return view('pages.'.$page->template, $this->data);
+    }
+}
index d13501ce7fea5e5b52c66a23b1cee0991dab52db..80e4a41639fd900905586a340ca8ef3f95ec65b0 100644 (file)
@@ -20,32 +20,31 @@ trait PageTemplates
     | - page slug
     */
 
-    private function services()
-    {
+    private function _meta(){
         $this->crud->addField([   // CustomHTML
-                        'name' => 'metas_separator',
-                        'type' => 'custom_html',
-                        'value' => '<br><h2>'.trans('backpack::pagemanager.metas').'</h2><hr>',
-                    ]);
-        $this->crud->addField([
-                        'name' => 'meta_title',
-                        'label' => trans('backpack::pagemanager.meta_title'),
-                        'fake' => true,
-                        'store_in' => 'extras',
-                    ]);
+            'name' => 'metas_separator',
+            'type' => 'custom_html',
+            'value' => '<br><h2>'.trans('backpack::pagemanager.metas').'</h2><hr>',
+        ]);
         $this->crud->addField([
-                        'name' => 'meta_description',
-                        'label' => trans('backpack::pagemanager.meta_description'),
-                        'fake' => true,
-                        'store_in' => 'extras',
-                    ]);
+            'name' => 'meta_title',
+            'label' => trans('backpack::pagemanager.meta_title'),
+            'type'=>'text',
+            'fake'=>true,
+            'store_in'=>'extras',
+        ]);
         $this->crud->addField([
-                        'name' => 'meta_keywords',
-                        'type' => 'textarea',
-                        'label' => trans('backpack::pagemanager.meta_keywords'),
-                        'fake' => true,
-                        'store_in' => 'extras',
-                    ]);
+            'name' => 'meta_description',
+            'label' => trans('backpack::pagemanager.meta_description'),
+            'type' => 'textarea',
+            'fake'=>true,
+            'store_in'=>'extras',
+        ]);
+    }
+
+    private function services()
+    {
+        $this->_meta();
         $this->crud->addField([   // CustomHTML
                         'name' => 'content_separator',
                         'type' => 'custom_html',
@@ -61,6 +60,7 @@ trait PageTemplates
 
     private function about_us()
     {
+        $this->_meta();
         $this->crud->addField([
                         'name' => 'content',
                         'label' => trans('backpack::pagemanager.content'),
diff --git a/resources/views/pages/about_us.blade.php b/resources/views/pages/about_us.blade.php
new file mode 100644 (file)
index 0000000..7d83d6d
--- /dev/null
@@ -0,0 +1,2 @@
+<?php
+echo 'about_us';
diff --git a/resources/views/pages/services.blade.php b/resources/views/pages/services.blade.php
new file mode 100644 (file)
index 0000000..d2ea39b
--- /dev/null
@@ -0,0 +1,8 @@
+services
+<?php
+/**
+ * Created by IntelliJ IDEA.
+ * User: Vincent
+ * Date: 19/02/2019
+ * Time: 15:41
+ */
index 810aa34949b08f9fae9892d008272d72c22c56d0..ff7354b5ba5694dfd724ea025cdc7d03d5150064 100644 (file)
@@ -14,3 +14,7 @@
 Route::get('/', function () {
     return view('welcome');
 });
+
+/** CATCH-ALL ROUTE for Backpack/PageManager - needs to be at the end of your routes.php file  **/
+Route::get('{page}/{subs?}', ['uses' => 'PageController@index'])
+    ->where(['page' => '^((?!admin).)*$', 'subs' => '.*']);