PHP code example of laker-ls / yii2-pencil

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

    

laker-ls / yii2-pencil example snippets


'modules' => [
    'pencil' => [
        'class' => '\lakerLS\pencil\Module',
        'params' => [
            'accessRoles' => ['admin'],
            'imagePath' => [
                'full' => 'upload/image-gallery/full',
                'mini' => 'upload/image-gallery/mini',
            ],
        ],
    ],
]

    public $categoryId;
    
    public function actionIndex($category)
    {
        // Где $category объект текущей категории.
        $this->categoryId = $category->id;
        
        // Если страница статическая, то можем задать `id` явно, но данный способ не является хорошей практикой.
        $this->categoryId = 1;
        
        return $this->render('view');
    }

use lakerLS\pencil\widgets\PencilText;
           
<?= PencilText::widget(['id' => 'example-id']) 

use lakerLS\pencil\widgets\PencilText;
           
<?= PencilText::widget(['id' => 'example-id', 'nonUnique' => 'this-name-layout']) 

use lakerLS\pencil\widgets\Pencil;
           
<?= PencilText::widget(['id' => 'example-id', 'tag' => 'h2', 'options' => ['class' => 'my-class']]) 


use lakerLS\pencil\widgets\PencilImage;

'modules'=>[
        'pencil' => [
            'class' => '\lakerLS\pencil\Module',
            'params' => [
                'imagePath' => [
                    'full' => 'upload/image-gallery/full', // Ваш путь к оригинальному изображению.
                    'mini' => 'upload/image-gallery/mini', // Ваш путь к миниатюре изображения.
                ],
            ],
            'controllerNamespace' => 'lakerLS\pencil\commands',
        ],
    ],

$ php composer.phar