Git Product home page Git Product logo

laravel-cms's Introduction

Laravel CMS

Total Downloads Latest Stable Version Latest Unstable Version License Monthly Downloads Daily Downloads composer.lock

A "plug-and-play" content managing system (CMS) for Laravel that does its job and stays out of your way.

Introduction

All of the existing Laravel CMS (OctoberCms, AsgardCms, PyroCms, etc) require a full installations from scratch. Its impossible to just add them to an exiting Laravel application, and even when added feel like you don't get what you hoped for.

This package allows to add a content management system as a package dependency in your composer file, which can be easily updated or removed as required to ANY Laravel app. It is fully self contained, and does not require any additional packages or dependencies. Removal is also a breeze just remove from your composer file.

Features

  • Templates (aka master layouts)
  • Pages (web pages)
  • Blocks (reusable cutom pieces of code -- headers, footers)
  • Widgets (dynamic reusable pre-defined components)

Installation (est. 5-10 mins)

  • Install required library
composer require lesichkovm/laravel-advanced-route
composer require lesichkovm/laravel-advanced-model
  • Install the CMS
composer require sinevia/laravel-cms
php artisan migrate
php artisan vendor:publish --tag=config
// If you want the migrations, usually not needed
php artisan vendor:publish --tag=migrations
// If you want the views, usually not  needed
php artisan vendor:publish --tag=views

Word of warning. Do use a stable package, as "dev-master" is a work in progress.

Uninstall (est. 5 mins)##

Removal of the package is a breeze:

composer remove sinevia/laravel-cms

Optionally, delete the CMS tables (all which start with the snv_cms_ prefix)

Configuration

After running the vendor:publish command, the CMS settings will be published in the /config/cms.php config file. Check these out, and modify according to your taste

Route Settings

  1. CMS Endpoint (public, catch all)
\Route::group(['prefix' => '/'], function () {
    // will match only one level deep (not recommended)
    \Route::any('/{path?}', '\Sinevia\Cms\Http\Controllers\CmsController@anyPageView');
    
    // or use with regex expression to match any level
    \Route::any('/{path?}', '\Sinevia\Cms\Http\Controllers\CmsController@anyPageView')
        ->where('path', '([a-zA-z0-9\/\-]++)');
        
    // or use with simpler regex expression to match any level
    \Route::any('/{path?}', '\Sinevia\Cms\Http\Controllers\CmsController@anyPageView')
        ->where('path', '.+');

    // or if you prefer using the class path (recommended)
    \Route::any('/{path?}', [\Sinevia\Cms\Http\Controllers\CmsController::class, 'anyPageView'])
        ->where('path', '.+');
});
  1. Admin endpoint (private, protect with middleware)
\Route::group(['prefix' => '/admin'], function () {
    \Route::group(['middleware'=>'adminonly'], function(){
        \AdvancedRoute::controller('/cms', '\Sinevia\Cms\Http\Controllers\CmsController');

        // or if your prefer using class path (recommended)
        \AdvancedRoute::controller('/cms', \Sinevia\Cms\Http\Controllers\CmsController::class);
    });
});

Templates

The templates are layouts, that can be used to display the pages in a uniform fashion. You may have multiple templates which is useful if you want to have different "look and feel" for different sections of your website.

Pages

The pages are the content which displays when you visit a specified URL. Each page may have an optional parent template, which can specify common elements (i.e. style sheets, scripts, etc) for all pages sharing the template.

Blocks

The blocks are small content snippets which can be embedded into pages and templates. Useful if you want to use on multiple pages, or to make pages more lightweight.

To embed in page or template use a shortcode like this: [[BLOCK_20180509052702261348]]

Widgets

The widgets are predefined dynamic modules which can be embedded into pages and templates (i.e. Google Maps, Contact Forms, etc). Depending on the action they perform, these may or may not have optional or requred parameters. Each widget files reside in its own directory.

To embed in page or template use a shortcode like this: [[WIDGET_20180509052702261348]]

More info: https://github.com/Sinevia/laravel-cms/wiki/Widgets

Human Friendly Aliases

The following shortcuts can be used to create human friendly page aliases, that can be used for pages with dynamic content

Shortcut Regex
:any ([^/]+)
:num ([0-9]+)
:all (.*)
:string ([a-zA-Z]+)
:number ([0-9]+)
:numeric ([0-9-.]+)
:alpha' ([a-zA-Z0-9-_]+)

Example page alias: /article/:num/:string

To retrieve back you may use the following snippet

preg_match('#^/article/([0-9]+)/([a-zA-Z]+)/([a-zA-Z]+)$#', '/' . $uri, $matched);
$articleId = $matched[1] ?? "";

Quick Snippets

  1. Advanced usage. Use the CMS templates to wrap around custom code with blade templates:
// A small helper function to place HTML in the CMS template
function viewInTemplate($pageTitle, $pageContent) {
    $template = \Sinevia\Cms\Models\Template::find('20180126000128528925');

    return $template->render('en', [
                'page_title' => $pageTitle,
                'page_content' => $pageContent,
    ]);
}

// Then you may use from your controller, for instance to show a login form in
$html = view('guest/auth/login', get_defined_vars())->render();
return viewInTemplate('Login', $pageContent)

Screenshots

1. Page Manager

Alt text

2. Create New Page

Alt text

3. Edit Page. Content View

Alt text

4. Edit Page. SEO View

Alt text

5. Speed Test (before additional speed improvements)

Alt text

Changelog

2021.07.05 - Added support for Bootstrap 5

Alternatives

  • LavaLite - requires full project from scratch, cannot be embedded in existing project as package
  • OctoberCms - requires full project from scratch, cannot be embedded in existing project as package
  • TypiCms - requires full project from scratch, cannot be embedded in existing project as package
  • PyroCMS - requires full project from scratch, cannot be embedded in existing project as package
  • Laravel8SimpleCms - requires full project from scratch, cannot be embedded in existing project as package
  • Winter - requires full project from scratch, cannot be embedded in existing project as package
  • GraphiteInc CMS - Archived
  • Twil

laravel-cms's People

Contributors

hamrak avatar lesichkovm avatar sinevia avatar

Stargazers

 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

laravel-cms's Issues

Page issues while creating

When opening url, getting middleware issue
https://headsocial.com/images/MqdUxPLQVXQ029P02IGh.png

route file
Route::group(['prefix' => '/cms-admin'], function () {
Route::group(['middleware'=>'adminonly'], function(){
AdvancedRoute::controller('/cms', '\Sinevia\Cms\Http\Controllers\CmsController');
});
});

When i am creating pages, these are not accessible
https://headsocial.com/images/qW77smHzjrqsHqxYlRSd.png

When viewing the page
https://headsocial.com/images/vL74ikylQTOZLa1IJE3e.png

All tables are present and system

Unknown column DeleteAt

After a clean installation according to the instructions, I get an error with a non-existent column after clicking the Translations button.

Snímka obrazovky 2023-11-13 o 11 26 50

Close button not work

Click on the "< Close" button doesn't work. Nothing. No JS error alert in debugger.

I use Bootstrap 5.

Snímka obrazovky 2023-11-13 o 11 36 24

vendor publish failure

running laravel 5.7 within current homestead environment.
running php migrate vendor:publish gives

Copied File [/vendor/sinevia/laravel-cms/config/cms.php] To [/config/cms.php]
Can't locate path: <0>
Can't locate path: <1>
Publishing complete.

Please Address the n + 1 query issues in rendering blocks and widgets

Please the below code in Models/Blade.php. To eliminate n + 1 querying situations, you could use some get request before running the loop inside renderBlocks function and remove self::find($blockID) part for each Block.

`public static function renderBlocks($string) {
    ....
    foreach ($blockIds as $blockId) {
        $content = self::renderBlock($blockId);
        $string = str_replace("[[BLOCK_$blockId]]", $content, $string);
    }
    return $string;
}`

`public static function renderBlock(string $blockId, array $options = []) {
    $block = self::find($blockId);
    if ($block == null) {
        return '';
    }
    ...
}`

Widgets

I am trying to add widgets in resources and added types for each widget..
Can we add questions or checkboxes for the particular widget?
Also let me know if I can reuse this widget in a page and form in that widget be shown as blank form so that whoever views the page can fill that form?

Please provide any links for documentation if available.

Thank you!

error when i wanted to add tranlation

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'Language' in 'field list' (SQL: insert into snv_cms_translation_value (KeyId, Language, Value, Id, UpdatedAt, CreatedAt) values (20201104005855860594, en, , 20201104005855865378, 2020-11-04 00:58:55, 2020-11-04 00:58:55))

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.