Git Product home page Git Product logo

pagemanager's Introduction

BackPack\PageManager

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads

An interface to let your admins add and edit presentation pages to your Laravel 6, 7, 8, 9 or 10 website, by defining page templates with any number of content areas and any number of content types. Uses Laravel Backpack.

Backpack PageManager edit page

Security updates and breaking changes

Please subscribe to the Backpack Newsletter so you can find out about any security updates, breaking changes or major features. We send an email every 1-2 months.

Install

  1. Add a file to define your page templates in app/PageTemplates.php:
<?php

namespace App;

trait PageTemplates
{
    /*
    |--------------------------------------------------------------------------
    | Page Templates for Backpack\PageManager
    |--------------------------------------------------------------------------
    |
    | Each page template has its own method, that define what fields should show up using the Backpack\CRUD API.
    | Use snake_case for naming and PageManager will make sure it looks pretty in the create/update form
    | template dropdown.
    |
    | Any fields defined here will show up after the standard page fields:
    | - select template
    | - page name (only seen by admins)
    | - page title
    | - page slug
    */

    private function services()
    {
        $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',
                    ]);
        $this->crud->addField([
                        'name' => 'meta_description',
                        'label' => trans('backpack::pagemanager.meta_description'),
                        'fake' => true,
                        'store_in' => 'extras',
                    ]);
        $this->crud->addField([
                        'name' => 'meta_keywords',
                        'type' => 'textarea',
                        'label' => trans('backpack::pagemanager.meta_keywords'),
                        'fake' => true,
                        'store_in' => 'extras',
                    ]);
        $this->crud->addField([   // CustomHTML
                        'name' => 'content_separator',
                        'type' => 'custom_html',
                        'value' => '<br><h2>'.trans('backpack::pagemanager.content').'</h2><hr>',
                    ]);
        $this->crud->addField([
                        'name' => 'content',
                        'label' => trans('backpack::pagemanager.content'),
                        'type' => 'summernote',
                        'placeholder' => trans('backpack::pagemanager.content_placeholder'),
                    ]);
    }

    private function about_us()
    {
        $this->crud->addField([
                        'name' => 'content',
                        'label' => trans('backpack::pagemanager.content'),
                        'type' => 'summernote',
                        'placeholder' => trans('backpack::pagemanager.content_placeholder'),
                    ]);
    }
}
  1. In your terminal
composer require backpack/pagemanager
  1. Publish the views, migrations and the PageTemplates trait:
php artisan vendor:publish --provider="Backpack\PageManager\PageManagerServiceProvider"
  1. Run the migration to have the database table we need:
php artisan migrate
  1. [optional] Add a menu item for it:
# For Backpack v6
php artisan backpack:add-menu-content "<x-backpack::menu-item title='Pages' icon='la la-file-o' :link=\"backpack_url('page')\" />"
# For Backpack v5 or v4
php artisan backpack:add-sidebar-content "<li class='nav-item'><a class='nav-link' href='{{ backpack_url('page') }}'><i class='nav-icon la la-file-o'></i> <span>Pages</span></a></li>"

Usage

  1. Go to yourapp/admin/page and see how it works.
  2. Define your own templates in app/PageTemplates.php using the Backpack\CRUD API.

Example front-end

No front-end is provided (Backpack only takes care of the admin panel), but for most projects this front-end code will be all you need:

(1) Create a catch-all route at the end of your routes file:

/** CATCH-ALL ROUTE for Backpack/PageManager - needs to be at the end of your routes.php file  **/
Route::get('{page}/{subs?}', ['uses' => '\App\Http\Controllers\PageController@index'])
    ->where(['page' => '^(((?=(?!admin))(?=(?!\/)).))*$', 'subs' => '.*']);

(2) Create app\Http\Controllers\PageController.php that actually shows the page.

<?php

namespace App\Http\Controllers;

use Backpack\PageManager\app\Models\Page;
use App\Http\Controllers\Controller;

class PageController extends Controller
{
    public function index($slug, $subs = null)
    {
        $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);
    }
}

(3) Create the views for those templates (how those pages actually look - the HTML CSS JS) and place them in your resources/views/pages/ directory. Inside those blade files, you can use the $page variable. That's where all the page content is stored. For more complicated pages, you can also use fake fields in your page templates. You'll also find those attributes in the $page variable.

Note: if you find yourself in need of sending extra data to a view you load on multiple pages, you should consider using a view composer;

Extend

If you need to make any modifications to the controller, model or request, you should:

  • make sure config/backpack/pagemanager.php is published; if not, publish it using php artisan vendor:publish --provider="Backpack\PageManager\PageManagerServiceProvider";
  • create a new controller/model that extends the one in the package;
  • enter controller or model in the pagemanager.php config file, and that's the one that the CRUD will be using;

Optional: Mutator for fields using 'store_in' and 'fake' keys

Fake fields do not trigger individual mutators, they trigger the "fake column" mutator. For example instead of defining a setImageAttribute() mutator, please define a setExtrasAttribute() mutator. You'll have the $value then.

Change log

Please see CHANGELOG for more information what has changed recently.

Testing

$ composer test

Contributing

Please see CONTRIBUTING and CONDUCT for details.

Overwriting Functionality

If you need to modify how this works in a project:

  • create a routes/backpack/pagemanager.php file; the package will see that, and load your routes file, instead of the one in the package;
  • create controllers/models that extend the ones in the package, and use those in your new routes file;
  • modify anything you'd like in the new controllers/models;

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

Backpack is free for non-commercial use and 69 EUR/project for commercial use. Please see License File and backpackforlaravel.com for more information.

Hire us

We've spend more than 10.000 hours creating, polishing and maintaining administration panels on Laravel. We've developed e-Commerce, e-Learning, ERPs, social networks, payment gateways and much more. We've worked on admin panels so much, that we've created one of the most popular software in its niche - just from making public what was repetitive in our projects.

If you are looking for a developer/team to help you build an admin panel on Laravel, look no further. You'll have a difficult time finding someone with more experience & enthusiasm for this. This is what we do. Contact us - let's see if we can work together.

pagemanager's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pagemanager's Issues

Adding Fields to Page Manager - Where's the Model / Data?

Let's say that I add the following function to app/PageTemplates.php:

    private function test_me()
    {
        $this->crud->addField([
            'name' => 'testme',
            'label' => 'Test Me',
            'placeholder' => 'Test me placeholder',
        ]);
    }

This behaves as expected.

However, there are no fields named testme in the model so when I enter a value into the text input labelled Test Me it's not stored...anywhere!

I then changed the field to:

    private function test_me()
    {
        $this->crud->addField([
            'name' => 'testme',
            'label' => 'Test Me',
            'placeholder' => 'Test me placeholder',
            'fake' => true, // Look, pa, we're fake now!
        ]);
    }

...and my test was saved.

@tabacitu - this might be intended behaviour, however it's somewhat unintuitive to me and probably needs some documentation in the README.md; I'd write the documentation but I don't know what the intended behaviours are meant to be...

Ambiguous class resolution

I get this warning message upon installing this package:

Warning: Ambiguous class resolution, "Backpack\Settings\database\seeds\SettingsTableSeeder" was found in both "/home/vagrant/Code/Laravel/vendor/backpack/settings/src/database/seeds/SettingsTableSeeder.php" and "/home/vagrant/Code/Laravel/database/seeds/SettingsTableSeeder.php", the first will be used.

Page content is not saved

I've added a new function contact in the file PageTemplates.php like this:

private function contact()
    {
        $this->crud->addField([
            'name' => 'adres',
            'label' => 'Adres',
            'type' => 'address',
            'placeholder' => 'Oudstrijdersstraat 37, 8770 Ingelmunster',
            'store_as_json' => true
        ]);

        $this->crud->addField([
            'name' => 'telehpone',
            'label' => 'Telefoon',
            'type' => 'text',
            'placeholder' => '051/30 28 44',
            'store_in' => 'extras',
        ]);

        $this->crud->addField([
            'name' => 'email',
            'label' => 'Email',
            'type' => 'email',
            'placeholder' => '[email protected]',
            'store_in' => 'extras',
        ]);
    }

But when I fill in the form and save the data my custom fields (that I've added in my function) are not saved.

schermafbeelding 2017-10-27 om 14 09 04

CLI to extend the package

It would:

  1. create model that extends the one from vendor
  2. create crudcontroller that extends the one from vendor
  3. create request that extends the one from vendor
  4. inform the developer to copy-paste some routes in his route file

This would make it much easier to overwrite the default functionality.

What would make it ever easier would be for this to be done by default, during the installation process. But it would take another 2 steps, and that's a lot. We could do this for all packages, after we build the installer. And then:

  • modifying some Backpack behaviour would be so much easier;
  • you'd have the appropriate files (controllers, models, routes) insinde your app, so you understand how it works a lot easier;

Multiple PageTemplates

Is there any way that I can add different PageTemplates?

I tried to create one App\CenterPageTemplates.php and using it in a new controller. But when I change a template, I get error 404.

Can't upload images

I'm trying to edit the page form so I can upload an image with the post, however I can't get anything stored as a file or get the path stored in the database.

In PageTemplates.php:

$this->crud->addField([ 
            'name' => 'image',
            'label' => 'Photo',
            'type' => 'upload',
            'upload' => true,
            'fake' => true
        ]);

In Page.php:

public function setImageAttribute($value)
    {
    	Log::info('New Image upload:');
        Log::alert(json_encode($value));
        $attribute_name = "image";
        if (request()->hasFile($attribute_name) && request()->file($attribute_name)->isValid()) {
            throw new \Exception('xxxIT SHOULD WORK'); 
        }

        $disk = "public";
        $destination_path = "/uploads";       
        $this->uploadFileToDisk($value, $attribute_name, $disk, $destination_path);
    }

The log alert returns an empty array, so the image isn't even getting to the setImageAttribute function.

Any help would be greatly appreciated thanks!

Change service provider in documentation

Hi
It was
Cviebrock\EloquentSluggable\SluggableServiceProvider::class,
Backpack\PageManager\PageManagerServiceProvider::class,

It should be

Cviebrock\EloquentSluggable\ServiceProvider::class,
Backpack\PageManager\PageManagerServiceProvider::class,

Created Page but while opening shows 404

Using the admin panel, I created a new page. But when I click on the 'open', it throws 404. What am I missing?

I created a page named 'About us' with slug URL as 'about-us' and tried various URLs to view the page:
myapp/about-us
myapp/about_us
myapp/page/about-us

But everything throws 404 :(

can i use image type field with pagemanager module?

Hey
i tried to use page manager and it works when i add new text type field but when i change the type to image it does not work
and i get error page:

QueryException in Connection.php line 770: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'extras' at row 1 (SQL: update pages set extras = {"meta_title":"dfdsfdsf","meta_description":"fffff","meta_keywords":null,"slide1":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPkAAAD5CAYAAADlT5OQAAAgAElEQVR4nLy955Mj15mv2d92I3bj3pFET8pLM5JGmju62pi5s7FzTYzR1

is there a solution to do that?

404 Error when switching templates

Bug report

What I did:

What I expected to happen:

What happened:

What I've already tried to fix it:

Backpack, Laravel, PHP, DB version:

Change Routes

I created a class that extends PageCrudController and set a different route

<?php

namespace App\Http\Controllers;

class PageController extends \Backpack\PageManager\app\Http\Controllers\Admin\PageCrudController
{
    public function setup() {
        parent::setup();
        $this->crud->setRoute("XXXXXXXXX");
    }
}

Then, in pagemanager.php changed the Controller to use that class

<?php

return [
    // Change this class if you wish to extend PageCrudController
    'admin_controller_class' => 'App\Http\Controllers\PageController',

    // Change this class if you wish to extend the Page model
    'page_model_class'       => 'Backpack\PageManager\app\Models\Page',
];

Problem is, routes keep the same, only thing that change are the buttons like "Add Page"

php artisan route:list

I've seen that routes are hard-coded in setupRoutes()
in:
vendor\backpack\pagemanager\src\PageManagerServiceProvider.php


    public function setupRoutes(Router $router)
    {
        // Admin Interface Routes
        Route::group(['middleware' => ['web', 'admin'], 'prefix' => config('backpack.base.route_prefix', 'admin')], function () {
            $controller = config('backpack.pagemanager.admin_controller_class', $this->adminControllerClass);

            // Backpack\PageManager routes
            Route::get('page/create/{template}', $controller.'@create');
            Route::get('page/{id}/edit/{template}', $controller.'@edit');

            // This triggered an error before publishing the PageTemplates trait, when calling Route::controller();
            // CRUD::resource('page', $controller . '');

            // So for PageCrudController all routes are explicitly defined:
            Route::get('page/reorder', $controller.'@reorder');
            Route::get('page/reorder/{lang}', $controller.'@reorder');
            Route::post('page/reorder', $controller.'@saveReorder');
            Route::post('page/reorder/{lang}', $controller.'@saveReorder');
            Route::get('page/{id}/details', $controller.'@showDetailsRow');
            Route::get('page/{id}/translate/{lang}', $controller.'@translateItem');
            Route::resource('page', $controller);
        });
    }

Shouldn't it use the same route?

How to change the routes?

Fake Fields Cannot Retrieve Data Back

Bug report

What I did: i have installed Backpack Page manager

What I expected to happen: I Expected Fake Field Such meta Data to be retrieving data on edit but they donot

What happened:

What I've already tried to fix it:

Backpack, Laravel, PHP, DB version:

Unique predefined pages

I'm currently in need of unique pages (one page per template) which can only be edited but neither deleted nor a second one created.

Think of something like the imprint or privacy page, a contact page, some describing text and image for landing... (I think you get the idea)

I have currently implemented this functionality in a project of mine based on page manager and wonder if this should be integrated in this package.

If you find this useful I would prepare a PR to add this functionality here, otherwise I will create an extra package for this (as this is quite useful in many client projects).

[Proposal] Sidebars?

I was curious if there was some interest/want on the option of a "Sidebar" for pages, I was thinking similar to how "Page Templates" are used but instead of a whole new "SidebarTemplates" file, just add a new folder pages\sidebars and scan the directory. Because there generally shouldn't be much content dynamically being made in those (from what i can think of) save a step of editing that file and more bloat.

Thoughts/feedback?

Note: I have a sorta working prototype of doing it simply by working with the PageTempaltes files but think it might be something a lot of people are interested in.

Upload multiple in page template

I'm trying to upload multiple images on page edit form. In my PageTemplates.php I have

$this->crud->addField([ 
	    'name' => 'images',
	    'label' => 'Fotos',
	    'type' => 'upload_multiple',
	    'upload' => true,
	    'disk' => 'uploads',
	    'hint' => 'Some hint text.',
	    'fake' => true
	]);

In my Page model I have:

public function setImagessAttribute($value)
    {
        $attribute_name = "images";
        $disk = "uploads";
        $destination_path = "images/pages";

        $this->uploadMultipleFilesToDisk($value, $attribute_name, $disk, $destination_path);
    }

In my $disks array in config/filesystems.php I have:

'uploads' => [
    'driver' => 'local',
    'root' => public_path('uploads'),
],

But when I try to save the page I have 2 problems:

  • Images aren't saved in folder (folder is writeable!)
  • Not saved in database

In my database extras field for that page I get:

"images":[  
      {  

      },
      {  

      }
   ],

Issues adding images to templates

When I attempt to add an image in the PageTemplate using the following code:

$this->crud->addField([ // image
            'label'  => "Header Logo",
            'name'   => "img_header_logo",
            'type'   => 'image',
            'crop'         => true,
            'fake'         => true
        ]);

It will first allow me to upload an image, which is stored in the database.

If I display the image in a view, it works. However if I then edit the page, it preappends the websites URL to the image and therefore can no longer be used.

  1. Is this an issue or something I am doing?
  2. How can I just store the image as a file?

This is with PageManager

Adding user_id to hidden field

Hi,

I created a one-to-many relation between app/Models/Page.php and app/User.php. And added user_id in pages DB. This allows me to show/edit posts who owns it.

Now L5.4 does not allow to access a session in a constructor, I am wondering how to add a hidden field with value of user_id. Since $this->crud->addField is in constructor, I have difficulty to use it. Any solution for this?

<?php
namespace App\Http\Controllers\Admin;

use Auth;
use App\Models\Page;
use Backpack\PageManager\app\Http\Controllers\Admin\PageCrudController as OriginalPageCrudController;

class PageCrudController extends OriginalPageCrudController
{
    protected $user;

    public function __construct()
    {
        parent::__construct();
        $this->crud->setModel("App\Models\Page");

        $this->middleware(function ($request, $next) {
            $this->user= Auth::user();
            return $this->user->can('Pages') ? $next($request) : redirect(config('mycms.dashboard'));
        });

        $this->crud->addColumn([
            'name' => 'user_id',
            'type' => 'model_function',
            'function_name' => 'getWriterName',
        ]);

        $this->crud->addField([
            'name'  => 'user_id', 
            'type'  => 'hidden', 
            'value' => $this->user->id, // this does not work.
        ]);

    }
}

Cannot get page to display

I've installed the demo, then followed the directions on https://github.com/Laravel-Backpack/PageManager#example-front-end

Also ran the command to publish views, etc:

$ php artisan vendor:publish --provider="Backpack\PageManager\PageManagerServiceProvider"
Copied Directory [\vendor\backpack\pagemanager\src\resources\views] To [\resources\views]
Copied Directory [\vendor\backpack\pagemanager\src\database\migrations] To [\database\migrations]
Publishing complete for tag []!

When I go to open the page I get:

InvalidArgumentException in FileViewFinder.php line 137:
View [pages.services] not found.

in FileViewFinder.php line 137
at FileViewFinder->findInPaths('pages.services', array('C:\xampp\htdocs\backpack\resources\views')) in FileViewFinder.php line 79
at FileViewFinder->find('pages.services') in Factory.php line 174
at Factory->make('pages.services', array('title' => 'test', 'page' => object(Page)), array()) in helpers.php line 855
at view('pages.services', array('title' => 'test', 'page' => object(Page))) in PageController.php line 21
at PageController->index('test')
at call_user_func_array(array(object(PageController), 'index'), array('page' => 'test')) in Controller.php line 55
at Controller->callAction('index', array('page' => 'test')) in ControllerDispatcher.php line 44
at ControllerDispatcher->dispatch(object(Route), object(PageController), 'index') in Route.php line 189
at Route->runController() in Route.php line 144
at Route->run(object(Request)) in Router.php line 642
at Router->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in VerifyCsrfToken.php line 65
at VerifyCsrfToken->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in StartSession.php line 64
at StartSession->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 104
at Pipeline->then(object(Closure)) in Router.php line 644
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 618
at Router->dispatchToRoute(object(Request)) in Router.php line 596
at Router->dispatch(object(Request)) in Kernel.php line 267
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 46
at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 104
at Pipeline->then(object(Closure)) in Kernel.php line 149
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 116
at Kernel->handle(object(Request)) in index.php line 53

Seems like a problem with the view?

Extra fields not saved

Hi,
I've created some template in PageTemplates, but extras datas are not stored :(

I have missed something ?

Uncaught exception after deleting a PageTemplate

Hi guys, this is only a minor issue but I thought I'd flag it anyway.

Steps to reproduce:

  1. create a custom PageTemplate (e.g. "contact") defined within the trait at app\PageTemplates.php
  2. create a new page, assign the "contact" template and save
  3. delete the custom PageTemplate from app\PageTemplates.php
  4. attempt to edit the page created in step 2

You receive "BadMethodCallException in Controller.php line 82: Method [contact] does not exist."

public function setup() and public function __construct()

I found that PageCrudController in PageManager uses public function __construct() and UserCrudController in PermissionManager uses public function setup(). And other controllers also use public function __construct(), rather than public function setup().

Are there any differences? Should PageCrudController use public function setup()?

How to translate strings?

Hi, I need just static translate strings. But I do not know of any way except editing vendor's PageCrudController.php. For known reasons, I do not want to do this. Does anyone know a civilized way to translate PageManager?

conflict with SluggableServiceProvide

the newCrud and PageManager package have conflict wiht Sluggable package.
so please fix this .

NewsCrud use a diffirent version for sluggable package

Missing page curd controller when opening Pages in admin menu

I've looked through the issues and read the issues concerning pages. But nothing seems to work. I think I may have missed a step.
I have-

  • cloned demo
  • composer install
  • composer update

But I still get this error message in log. Any help would be greatly appreciated.
Thanks

2017-06-26 15:55:02] local.ERROR: ReflectionException: Class Backpack\PageManager\App\Http\Controllers\Admin\PageCrudController does not exist in /var/www/site/vendor/laravel/framework/src/Illuminate/Container/Container.php:729 Stack trace: #0 /var/www/site/vendor/laravel/framework/src/Illuminate/Container/Container.php(729): ReflectionClass->__construct('Backpack\\PageMa...') #1 /var/www/site/vendor/laravel/framework/src/Illuminate/Container/Container.php(608): Illuminate\Container\Container->build('Backpack\\PageMa...') #2 /var/www/site/vendor/laravel/framework/src/Illuminate/Container/Container.php(575): Illuminate\Container\Container->resolve('Backpack\\PageMa...') #3 /var/www/site/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(728): Illuminate\Container\Container->make('Backpack\\PageMa...') #4 /var/www/site/vendor/laravel/framework/src/Illuminate/Routing/Route.php(217): Illuminate\Foundation\Application->make('Backpack\\PageMa...') #5 /var/www/site/vendor/laravel/framework/src/Illuminate/Routing/Route.php(747): Illuminate\Routing\Route->getController() #6 /var/www/site/vendor/laravel/framework/src/Illuminate/Routing/Route.php(708): Illuminate\Routing\Route->controllerMiddleware() #7 /var/www/site/vendor/laravel/framework/src/Illuminate/Routing/Router.php(587): Illuminate\Routing\Route->gatherMiddleware() #8 /var/www/site/vendor/laravel/framework/src/Illuminate/Routing/Router.php(567): Illuminate\Routing\Router->gatherRouteMiddleware(Object(Illuminate\Routing\Route)) #9 /var/www/site/vendor/laravel/framework/src/Illuminate/Routing/Router.php(535): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request)) #10 /var/www/site/vendor/laravel/framework/src/Illuminate/Routing/Router.php(513): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request)) #11 /var/www/site/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(174): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request)) #12 /var/www/site/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(Object(Illuminate\Http\Request)) #13 /var/www/site/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(46): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) #14 /var/www/site/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure)) #15 /var/www/site/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #16 /var/www/site/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) #17 /var/www/site/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(149): Illuminate\Pipeline\Pipeline->then(Object(Closure)) #18 /var/www/site/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request)) #19 /var/www/site/public/index.php(52): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request)) #20 {main}

display fakefields in view?

Hi,
im creating a master layout and i would like to display the metas in the head..for the title im using {{$title}} and it works..
{{$page->title}} also works.. because title is in its own column.. but what about the extras column?
when i use {{$page -> extras}} i get {"meta_title":"services","meta_description":"services","meta_keywords":"services"} as an echo but how do i select which of the above to show?
ive tried using dot annotation like {{$page->extras.meta_title}}, and {{$page->extras->meta_title}}, and {{$page->extras[meta_title]}} but none of them work..
how can i pass these values separately in the view?
any pointer would be great.. thanks.

Set extra attributes before save

In my PageTemplates.php I have a field like this:

$this->crud->addField([
	'name' => 'adres',
	'label' => 'Adres',
	'type' => 'address',
	'fake' => true,
]);

Now I would like to save also the latitude and longitude of the address they give in (if it can be found). I've copied the PageCrudController and changed the config in config/backpack/pagemanager.php to:

return [
    'admin_controller_class' => 'App\Http\Controllers\Admin\PageCrudController',
    'page_model_class'       => 'App\Models\Page',
];

In my store function I have:

public function store(StoreRequest $request)
{
    $address = $request->request->get('adres');
    $addressObj = app('geocoder')->geocode($address)->get()->first();

    if($addressObj)
    {
        
    }

    $this->addDefaultPageFields(\Request::input('template'));
    $this->useTemplate(\Request::input('template'));

    return parent::storeCrud();
}

But what do I place in the if statement? How can I add (= set) an extra field to the extras field in my database?

Sharing fields using protected methods

By default the sample pages are defined as private methods. In the interest of keeping the template definitions organized it would be nice to define "fieldsets", so to speak, as protected methods from inside the private method which defines the page. This allows for re-use and de-cluttering if you're adding (for example) the same meta fields to several pages types.

Currently, attempting this causes the method created for the fields to show up in the template drop down menu in the admin panel. If a filter is added to the reflection on trait we can separate these methods.

#34

I have fix, but can`t push it

Bug report

When enable revisions to PageManager, it not resolve revisions URI`s
Like this one - http://127.0.0.1:8000/admin/page/2/revisions
Server returns 404 error

What I did:

Fix by add revision routes to PageManager, but i can`t make git push to this repo.

What I've already tried to fix it:

Please add this two strings to /pagemanager/src/routes/backpack/pagemanager.php

Route::get('page/{id}/revisions', $controller.'@listRevisions');
Route::post('page/{id}/revisions/{revisionId}/restore', $controller.'@restoreRevision');

Missing "use" in Readme

Please add

use App\Http\Controllers\Controller;

to the PageController Example. The one displayed results in HTTP 502

404 Page not found

I ran composer update on my Backpack demo project and now the route for /admin/page results in a 404. It was working fine before the update. I'm using the Backpack 3.0 Demo. I think it has something to do with the new Laravel 5.3 route changes. .... any thoughts?

Ability to config the location of PageTemplates

Suggestion

Does it make sense for developers to be able to configure the location of PageTemplates.php?
If possible I would like to be able to move PageTemplates.php inside a folder, just to keep the project organized.

There is the possibility to extend page_model_class and thereafter, manually relocate PageTemplates.php, but by adding an extra parameter to config maybe a page_template_class, it would be easier to just relocate PageTemplates.php.

If you agree with this, I can help with a PR!

how to create page template for new Model

I have categories and Products Models. I need to display products by categories and individual products details. But i am not getting any ideas how to display them in custom templates (frontend).

Cannot view created page

Hi,

Using the PageManager, I created a simple page with a slug as 'about'. I am unable to view this page when I click on Preview (redirects to url myapp/about), I receive a 404 error.

I tried various URLs to view the page. I receive a 404 error on the below urls
myapp/about
myapp/page/about
myapp/admin/about

I receive a 403 error on the below paths for this url - myapp/admin/page/about

Overriding PageRequest - not possible

Sorry if I am going crazy but I can't figure this out.

I need to override Backpack\PageManager\app\Http\Requests\PageRequest class

to change the authorize method so that it uses my custom authentication method rather than the standard Illuminate Auth check.

I have created App\Http\Requests\PageRequest but that does not override it.

So I tried to create my own PageCrudController as follows:

<?php

namespace App\Http\Controllers\Admin;

use Backpack\PageManager\app\Http\Controllers\Admin\PageCrudController as BackpackPageCrudController;
use App\Http\Requests\PageRequest as StoreRequest;
use App\Http\Requests\PageRequest as UpdateRequest;

class PageCrudController extends BackpackPageCrudController
{
    public function store(StoreRequest $request)
    {
        $this->addDefaultPageFields(\Request::input('template'));
        $this->useTemplate(\Request::input('template'));

        return parent::storeCrud();
    }

    public function update(UpdateRequest $request)
    {
        $this->addDefaultPageFields(\Request::input('template'));
        $this->useTemplate(\Request::input('template'));

        return parent::updateCrud();
    }
}

Now I receive:

Declaration of App\Http\Controllers\Admin\PageCrudController::store(App\Http\Requests\PageRequest $request) should be compatible with Backpack\PageManager\app\Http\Controllers\Admin\PageCrudController::store(Backpack\PageManager\app\Http\Requests\PageRequest $request)

How can I override it with this conflict?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.