PHPackages                             almeyda/yii2-emcms - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. almeyda/yii2-emcms

ActiveYii2-extension[Framework](/categories/framework)

almeyda/yii2-emcms
==================

basic yii2 content management extension to create simple sites

010PHP

Since Nov 26Pushed 4y ago1 watchersCompare

[ Source](https://github.com/willarin/yii2-emcms)[ Packagist](https://packagist.org/packages/almeyda/yii2-emcms)[ RSS](/packages/almeyda-yii2-emcms/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependenciesVersions (1)Used By (0)

Emcms Content Management Module
===============================

[](#emcms-content-management-module)

Emcms is a simple client-side Content Management Module for Yii2.

Installation
------------

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Place **composer.phar** file in the same directory with **composer.json** file and run

```
$ php composer.phar require almeyda/yii2-emcms "dev-master"

```

or add

```
{
    ...
    "require": {
        ...
        "almeyda/yii2-emcms": "dev-master"
        ...
    }
    ...
}

```

to the *"require"* section of your `composer.json` file and run

```
$ php composer.phar update

```

Update database schema
----------------------

[](#update-database-schema)

The last thing you need to do is updating your database schema by applying the migrations. Make sure that you have properly configured `db` application component and run the following command:

```
$ php yii migrate/up --migrationPath=@vendor/almeyda/yii2-emcms/migrations
```

Configuration
-------------

[](#configuration)

Once the extension is installed, modify your application configuration to include:

```
return [
    ...
    'modules' => [
        ...
        'emcms' => [
           'class' => 'almeyda\emcms\Module',
        ],
        ...
    ],
    ...
    'components' => [
        ...
        'urlManager' => [
            'class' => 'codemix\localeurls\UrlManager',
            'rules' => [
                ...
                ...
                ...
                'emcms' =>  [
                        'pattern' => '',
                        'route' => 'emcms/page/page',
                        'defaults' => ['view' => 'index'],
                ],
                ...
            ]
        ...
        ],
    ],
    ...
]
];
```

Please note that rule 'emcms' should be added at the end of the rules stack. Otherwise all simple requests will be processed by the emcms module.

Overriding views
----------------

[](#overriding-views)

When you start using yii2-emcms you will probably find that you need to override the default views provided by the module. Although view names are not configurable, Yii2 provides a way to override views using themes. To get started you should configure your view application component as follows:

```
...
'components' => [
    'view' => [
        ...
        'theme' => [
            'pathMap' => [
                '@almeyda/emcms/views/layouts' => '@app/views/emcms/layouts',
                '@almeyda/emcms/views' => '@app/views/emcms/pages',
                ...
        ],
        ...
    ],
],
...
```

In the above `pathMap` means that every view in @almeyda/emcms/views will be first searched under `@app/views/emcms/pages` and if a view exists in the theme directory it will be used instead of the original view.

Usage
-----

[](#usage)

Create your index.php page in your theme folder and add your pages to this folder (like post1.php, post2.php, ...)

\##Example structure of the folders:

```
views/                        (folder) main folder in the root of your site
    └─emcms/                  (folder) - folder containing all cms related views/layouts
        ├─layout/             (folder) - folder containing layout
            └main.php         (file) - layout name. It matches 'pathMap' in the configuration
        └─pages/              (folder) - folder containing all the views. It matches 'pathMap' in the configuration
            ├─ index.php      (file) - file with the list of posts
            ├─ post1.php      (file) - file with the content of 1st post
            └─ post2.php      (file) - file with the content of 2nd post

```

### File examples

[](#file-examples)

**\[main.php\]**layout used

```
