Coder Social home page Coder Social logo

yii2-posts's Introduction

Posts Module

Module for different type of post, like articles, news, blog post etc. ERR Diagram

Dependencies

    use \kartik\switchinput\SwitchInput;
    use mihaildev\ckeditor\CKEditor;
    use mihaildev\elfinder\ElFinder;
    
"porcelanosa/yii2-toggle-column": "*",

Installation

1. Run composer

composer require porcelanosa/yii2-posts

2. Common config

Add to 'common/config/main.php'

 
    ......
    'modules' => [
        'posts' => [
            'class' => 'porcelanosa\posts\Module',
        ],
    ],
    ......

3. Backend config

Add to 'backend/config/main.php

'module' => [
    ...
    'posts' => [
        'class'  => 'porcelanosa\posts\Module',
            'controllerMap' => [
                'cpposts' => [
                    'class'     => 'porcelanosa\posts\controllers\AdminController',
                    'as access' => [
                        'class' => \yii\filters\AccessControl::className(),
                        'rules' => [
                            [
                                'allow' => true,
                                'roles' => ['admin'],
                                ],
                            ],
                        ],
                    ],
                ],
            ],
    ...

If you rename CintrollerMap name from 'cpposts' you must rename 'modules/posts/views/cppost/' folder also.

4. Migration

Run migration

yii migrate --migrationPath=@vendor/porcelanosa/yii2-posts/migrations

5. Routes

Add rules to UrlManager For example,

// posts with post_types 'articles'
[
    'pattern' => 'articles',
    'route' => 'posts/default/index',
    'defaults' => ['post_type_slug' => 'articles'],
],
[
    'pattern' => 'articles/<cat_slug>/<slug>',
    'route' => 'posts/default/view',
    'defaults' => ['post_type_slug' => 'articles'],
],
// posts with post_types 'news'
[
    'pattern' => 'news',
    'route' => 'posts/default/index',
    'defaults' => ['post_type_slug' => 'news'],
],
[
    'pattern' => 'news/<cat_slug>/<slug>',
    'route' => 'posts/default/view',
    'defaults' => ['post_type_slug' => 'news'],
],
//'confirm-order' => 'cart/confirmorder',
// Posts
[
    'pattern' => 'posts/<post_type_slug>/<cat_slug>/<slug>',
    'route' => 'posts/default/view'
],
[
    'pattern' => 'posts/<post_type_slug>/<cat_slug>',
    'route' => 'posts/default/catview'
],
[
    'pattern' => 'posts/<post_type_slug>',
    'route' => 'posts/default/index'
],

or different for route to 'posts/default/view'

6. Add module to bootstrap

Add

'bootstrap'           => ['posts'],

to common/config/main.php

yii2-posts's People

Contributors

porcelanosa avatar

Watchers

 avatar James Cloos 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.