Coder Social home page Coder Social logo

hu19891110 / pagemanager Goto Github PK

View Code? Open in Web Editor NEW

This project forked from laravel-backpack/pagemanager

0.0 2.0 0.0 74 KB

Create admin panels for presentation websites on Laravel, using page templates and Backpack\CRUD

Home Page: http://backpackforlaravel.com

License: Other

PHP 100.00%

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 5 website, by defining page templates with any number of content areas and any number of content types. Uses Laravel Backpack.

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. In your terminal
$ composer require backpack/pagemanager
  1. Then add the service providers to your config/app.php file:
Cviebrock\EloquentSluggable\ServiceProvider::class, 
Backpack\PageManager\PageManagerServiceProvider::class,
  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 in resources/views/vendor/backpack/base/inc/sidebar.blade.php or menu.blade.php:
<li><a href="{{ url(config('backpack.base.route_prefix').'/page') }}"><i class="fa fa-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' => '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)
    {
        $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;

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 $19/project for commercial use. Please see License File and backpackforlaravel.com for more information.

pagemanager's People

Contributors

tabacitu avatar abbyjanke avatar unstoppablecarl avatar f-liva avatar carlosrgzm avatar lloy0076 avatar eduardoarandah avatar michaellindahl avatar nickbarrettjb avatar theycallmepepper avatar

Watchers

hadi avatar  avatar

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.