PHP code example of afzalroq / yii2-unit

1. Go to this page and download the library: Download afzalroq/yii2-unit library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

afzalroq / yii2-unit example snippets


'modules' => [
    'unit' => [ // don`t change module key
        'class' => '@afzalroq\unit\Module',
        'storageRoot' => $params['staticPath'],
        'storageHost' => $params['staticHostInfo'],
        'thumbs' => [ // 'sm' and 'md' keys are reserved
            'admin' => ['width' => 128, 'height' => 128],
            'thumb' => ['width' => 320, 'height' => 320],
        ],
        'languages' => [
            'ru' => [
                'id' => 0,
                'name' => 'Русский',
            ],
            'uz' => [
                'id' => 1,
                'name' => 'English',
            ],
        ],
    ],
]

/unit/categories/index
/unit/units/index?slug=your_category_slug_name

\Yii::$app->params['cms']['languageIds'][$prefix] = $language['id'];
[
    'en' => 2,
    'ru' => 1,
    ...
]

\Yii::$app->params['cms']['languages'][$prefix] = $language['name'];
[
    'en' => 'English',
    ...
]


\Yii::$app->params['cms']['languages2'][$language['id']] = $language['name'];
[
    2 => 'English',
    ...
]
bash
php yii migrate/up --migrationPath=@vendor/afzalroq/yii2-unit/migrations

$units = Unit::getBySlug($slug);
foreach ($units as $unit) {
    echo ($blockObject->getModelByType())->get();
}