execut/yii2-settings

Yii2 module for settings managing with CRUD

Installs: 398

Dependents: 2

Suggesters: 0

Security: 0

Stars: 3

Watchers: 2

Forks: 1

Open Issues: 4

Type:yii2-extension

0.11.1 2021-12-02 09:48 UTC

README

Yii2 module for application configuring via administrate crud settings. The module can used both separately and as part of the execut/yii2-cms.

Installation

The preferred way to install this extension is through composer.

Install

Either run

$ php composer.phar require execut/yii2-settings

or add

"execut/yii2-settings": "dev-master"

to the require section of your composer.json file.

Configuration

Add module bootstrap to backend application config:

    'bootstrap' => [
    ...
        'settings' => [
            'class' => \execut\settings\bootstrap\Backend::class,
        ],
    ...
    ],

Add module bootstrap to common application config:

    'bootstrap' => [
    ...
        'settings' => [
            'class' => \execut\settings\bootstrap\Common::class,
        ],
    ...
    ],

Add module bootstrap inside console application config:

    'bootstrap' => [
    ...
        'settings' => [
            'class' => \execut\settings\bootstrap\Console::class,
        ],
    ...
    ],

Apply migrations via yii command:

./yii migrate/up --interactive=0

After configuration, the module should open by paths: settings/backend

Module navigation

You may output navigation of module inside your layout via execut/yii2-navigation:

    echo Nav::widget([
        ...
        'items' => \yii\helpers\ArrayHelper::merge($menuItems, \yii::$app->navigation->getMenuItems()),
        ...
    ]);
    NavBar::end();

    // Before standard breadcrumbs render breadcrumbs and header widget:
echo \execut\navigation\widgets\Breadcrumbs::widget();
echo \execut\navigation\widgets\Header::widget();
echo Breadcrumbs::widget([
    'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
]);

For more information about execut/yii2-navigation module, please read it documentation

Usage

Settings administration

Settings list

Section contains the following columns:

For example, we want to manage the site name. To do this, add a setting with the key site_name:

Setting edit

On the website we can display this parameter using this line:

<?= \yii::$app->settings->get('company-name') ?>

Increase functionality

For adding more functionality inside module you can create plugin based on interface execut\settings\Plugin and connect it to module via common bootstrap depends config:

    'bootstrap' => [
    ...
        'settings' => [
            'class' => \execut\settings\bootstrap\Common::class,
            'depends' => [
                'modules' => [
                    'settings' => [
                        'plugins' => [
                            'own-plugin' => [
                                'class' => $pluginClass // You plugin class here
                            ],
                        ],
                    ]
                ],
            ],
        ],
    ...
    ],

He has next methods: