shoxabbos/yii2-localpages

Create local pages

Installs: 37

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 2

Forks: 2

Type:yii2-extension

v2.1.0 2017-08-30 14:40 UTC

This package is not auto-updated.

Last update: 2024-04-19 22:06:06 UTC


README

Create multi language static pages

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist shoxabbos/yii2-localpages "*"

or add

"shoxabbos/yii2-localpages": "*"

to the require section of your composer.json file.

Usage

Once the extension is installed, simply use it in your code by :

Run migrate

php yii migrate --migrationPath=@vendor/shoxabbos/yii2-localpages/migrations

Add module to web/config

'modules' => [
    'pages' => [
        'class' => '\shoxabbos\localpages\Module',
        'langs' => [
            'ru' => 'Russian',
            'en' => 'English',
        ],
        'defaultRoute' => 'page',
        'defaultLang' => 'ru',
        'layoutPath' => '@app/path/to/layouts',
        'layout' => 'admin',
        'pagesTableName' => 'pages',
        'pagesContentTableName' => 'page_contents',
    ],
]

Add action to your controller (viewFile: your view file for showing pages)

public function actions()
{
    return [
        'page' => [
            'class' => 'shoxabbos\localpages\actions\ViewAction',
            'viewFile' => 'page'
        ],
    ];
}

For add news: http://localhost:8080/pages/page/create

For see created your post: http://localhost:8080/site/page?slug=test

If you want a nice url you can set up the URL manager:

'page/<slug:\w+>' => 'site/page'

After that, you can open the pages as:

Before: http://localhost:8080/site/page?slug=test

After: http://localhost:8080/page/test