wdmg/yii2-news

News manager

Installs: 5

Dependents: 1

Suggesters: 0

Stars: 2

Watchers: 3

Forks: 2

Open Issues: 0

Type:yii2-extension

1.0.2 2019-08-06 12:14 UTC

README

Yii2 Github all releases Progress GitHub license GitHub release

Yii2 News

News module for Yii2

Requirements

Installation

To install the module, run the following command in the console:

$ composer require "wdmg/yii2-news"

After configure db connection, run the following command in the console:

$ php yii news/init

And select the operation you want to perform:

  1. Apply all module migrations
  2. Revert all module migrations

Migrations

In any case, you can execute the migration and create the initial data, run the following command in the console:

$ php yii migrate --migrationPath=@vendor/wdmg/yii2-news/migrations

Configure

To add a module to the project, add the following data in your configuration file:

'modules' => [
    ...
    'news' => [
        'class' => 'wdmg\news\Module',
        'routePrefix' => 'admin',
        'newsRoute'  => '/news', // route for frontend (string or array), use "/" - for root
        'newsLayout' => '@app/views/layouts/main', // the default layout to render news
        'newsImagePath' => '/uploads/news' // the default path to save news thumbnails in @webroot
    ],
    ...
],

Routing

Use the Module::dashboardNavItems() method of the module to generate a navigation items list for NavBar, like this:

<?php
    echo Nav::widget([
    'options' => ['class' => 'navbar-nav navbar-right'],
        'label' => 'Modules',
        'items' => [
            Yii::$app->getModule('news')->dashboardNavItems(),
            ...
        ]
    ]);
?>

Status and version [in progress development]

  • v.1.0.2 - Added news image and thumbnails, draft view from backend
  • v.1.0.1 - Added module views and updating controllers
  • v.1.0.0 - Added models, controllers and base views