PHP code example of heggi / yii2-posts

1. Go to this page and download the library: Download heggi/yii2-posts 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/ */

    

heggi / yii2-posts example snippets


'modules' => [
    'news' => [
        'class' => 'heggi\yii2posts\Module',
        'controllerNamespace' => 'heggi\yii2posts\controllers\backend',
        //Если нужен CKEditor
        'ckeditor' => [
            'preset' => 'full',
        ],
        //Если нужен ElFinder
        'elfinder' => true,
        //Нужно ли отображать поле slug в админке
        'showSlug' => false,
        //Нужно ли отображать поле Отрывок в админке
        'showExcerpt' => false,
    ],
],

'controllerMap' => [
    'elfinder' => [
        'class' => 'mihaildev\elfinder\PathController',
        'access' => ['@'],
        'root' => [
            'baseUrl' => '',
            'basePath' => '@webroot/..',
            'path' => 'uploads',
            'name' => 'Загрузки'
        ],
    ],
],

'modules' => [
    'news' => [
        'class' => 'heggi\yii2posts\Module',
        'controllerNamespace' => 'heggi\yii2posts\controllers\frontend',
        //Переопределяем шаблоны для рендеринга фронтэнда
        'views' => [
            //Главная
            'index' => '//news/index',
            //Отображение одной записи
            'single' => '//news/single',
        ]
    ],
],

'rules' => [
    //Главная страница со списком
    'news' => 'news/render/index',
    //Если адресация к записи по ID
    'news/<id:\d+> => 'news/render/single-id',
    //Если адресация к записи по SLUG
    'news/<slug:\w+> => 'news/render/single-slug',
],

'modules' => [
    'news' => [
        //Название в единственном числе
        'nameSingle' => 'Новость',
        //Название во множественном числе
        'nameMultiple' => 'Новости',
        //Для кнопки Новая Запись
        'nameNew' => 'Новая новость',
        //Если нужна возможность прикрепления файлов и изображений к новости посредством модуля heggi/yii2-files
        'files' => [
            //Ключ - название элемента
            'preview' => [
                //Метка с названием для админки
                'label' => 'Главное изображение',
                //Множественная загрузка или 1 файл
                'multiple' => false,
                //Опции для элемента fileInput в админке
                'options' => ['accept' => 'image/*'],
                //Позиция в админке
                'position' => 'sidebar' //sidebar or main
            ],
        ],
    ],
]