{"id":15282328,"url":"https://github.com/nullrefexcep/yii2-cms","last_synced_at":"2025-04-12T22:54:57.139Z","repository":{"id":57029276,"uuid":"45111121","full_name":"NullRefExcep/yii2-cms","owner":"NullRefExcep","description":"Content Management Module for Yii2","archived":false,"fork":false,"pushed_at":"2020-07-26T11:54:45.000Z","size":526,"stargazers_count":9,"open_issues_count":7,"forks_count":5,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-12T22:54:54.827Z","etag":null,"topics":["cms","php","yii2","yii2-cms","yii2-extension","yii2-modules"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NullRefExcep.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-10-28T12:34:09.000Z","updated_at":"2024-11-01T00:47:44.000Z","dependencies_parsed_at":"2022-08-23T16:30:10.184Z","dependency_job_id":null,"html_url":"https://github.com/NullRefExcep/yii2-cms","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NullRefExcep%2Fyii2-cms","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NullRefExcep%2Fyii2-cms/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NullRefExcep%2Fyii2-cms/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NullRefExcep%2Fyii2-cms/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NullRefExcep","download_url":"https://codeload.github.com/NullRefExcep/yii2-cms/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248643048,"owners_count":21138353,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cms","php","yii2","yii2-cms","yii2-extension","yii2-modules"],"created_at":"2024-09-30T14:25:09.640Z","updated_at":"2025-04-12T22:54:57.122Z","avatar_url":"https://github.com/NullRefExcep.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Content Management Module for Yii2\n====================\n[![Latest Stable Version](https://poser.pugx.org/nullref/yii2-cms/v/stable)](https://packagist.org/packages/nullref/yii2-cms) [![Total Downloads](https://poser.pugx.org/nullref/yii2-cms/downloads)](https://packagist.org/packages/nullref/yii2-cms) [![Latest Unstable Version](https://poser.pugx.org/nullref/yii2-cms/v/unstable)](https://packagist.org/packages/nullref/yii2-cms) [![License](https://poser.pugx.org/nullref/yii2-cms/license)](https://packagist.org/packages/nullref/yii2-cms)\n\nInstallation\n------------\n\nThe preferred way to install this extension is through [composer](http://getcomposer.org/download/).\n\nEither run\n\n```\nphp composer.phar require --prefer-dist nullref/yii2-cms \"*\"\n```\n\nor add\n\n```\n\"nullref/yii2-cms\": \"*\"\n```\n\nto the require section of your `composer.json` file.\n\nRun command `php yii module/install nullref/yii2-cms` to install this module. It will be added to your application config (`@app/config/installed_modules.php`)\n\nConcept\n-------\n\nThis module allows you to build dynamic pages which consist of blocks (widget with config).\nYou can create custom widgets and register it in BlockManager.\n\nAlso you can create pages with html content by WYSIWYG [CKEditor](https://github.com/MihailDev/yii2-ckeditor).\n\n[User Guide](https://github.com/NullRefExcep/yii2-cms/blob/master/docs/UserGuide.md)\n------------\n\nBlockManager\n------------\n\nThis component contains information about available blocks.\nYou can override it:\n\n```php\n    'cms' =\u003e [\n        'class' =\u003e 'nullref\\\\cms\\\\Module',\n        'components' =\u003e [\n            'blockManager' =\u003e 'app\\components\\BlockManager',\n        ]\n    ],\n```\n\nand add in your class own blocks:\n\n```php\nclass BlockManager extends BaseBlockManager\n{\n    public function getList()\n    {\n        return array_merge([\n            'smile' =\u003e 'app\\blocks\\smile', //namespace of block files\n        ], parent::getList());\n    }\n}\n```\n\nTo register block at runtime:\n\n```php\n    Block::getManager()-\u003eregister('smile','app\\blocks\\smile');\n    //or\n    Yii::$app-\u003egetModule($moduleId)-\u003eget('blockManager')-\u003eregister('smile','app\\blocks\\smile');\n```\n\nLinkManager\n-----------\n\nThis component is used for unified access to links of different resources (e.g. page or categories).\nManager can generate link to resource by it type and id.\nIf you want to add own type of links you need to add link provider to this manager by definition container (DI).\nFor example:\n```php\nYii::$container-\u003eset(LinkManager::className(), [\n    'class' =\u003e LinkManager::className(),\n    'providers' =\u003e [\n        'page' =\u003e [\n            'class' =\u003e 'app\\modules\\cms\\components\\PageLinkProvider',\n        ],\n],]);\n```\nEach link provider must to impelement [LinkProvider](https://github.com/NullRefExcep/yii2-cms/blob/master/src/components/LinkProvider.php) interface.\n\nAs result you can use this manager to generate link in your widgets or other application parts.\nE.g:\n```php\n/** in some component constructor define additional parameter and set it in class property **/\npublic function __construct(LinkManager $linkManager, $config = [])\n{\n    $this-\u003elinkManager = $linkManager;\n    parent::__construct($config);\n}\n/** generate link **/\necho $this-\u003elinkManager-\u003ecreateUrl('page', $id);\n```\n\n\nBlock structure convention\n--------------------------\n\nA valid block is represented by a folder with two classes:\n\n- Block - define data block to use\n- Widget - run with data when this block use on page\n\nIn most cases form file will also be in this folder\n\nWhen you add own block you have to set unique id and namespace of block files folder.\n\n\nSingle block usage\n------------------\n\nYou can use cms blocks on you own views, to call by id:\n\n```php\nuse nullref\\cms\\components\\Block;\n?\u003e\n\u003cdiv class=\"site-index\"\u003e\n    \u003c?= Block::getBlock('hello')-\u003erun() ?\u003e\n    or\n    \u003c?= Block::getBlock('hello2') //block has override method __toString() ?\u003e\n\u003c/div\u003e\n```\n\n\nPages\n-----\n\nThis module allows to create pages with custom content and set custom url for it.\nBy default all pages are available by route `/pages/\u003croute\u003e`, but you can override it by config:\n```php\n/** module config **/\n'cms' =\u003e [\n    'class' =\u003e 'nullref\\cms\\Module',\n    'urlPrefix' =\u003e '', //make empty prefix\n],\n```\n\nBy default you can set meta tags for each page.\nDefault tags are:\n\n- title\n- description\n- keywords\n- robots\n\nYou can override method `getMetaTypesList` in Page model class ([see below](#overriding)) to extend it.\n\n\nOverriding\n--------\n\n- Models and ActiveQueries:\n```php\n/** module config **/\n'cms' =\u003e [\n    'classMap' =\u003e [\n        'Block' =\u003e 'app\\models\\cms\\Block',\n        'BlockQuery' =\u003e 'app\\models\\cms\\BlockQuery',\n        'Page' =\u003e 'app\\models\\cms\\Page',\n        'PageHasBlock' =\u003e 'app\\models\\cms\\PageHasBlock',\n        'PageQuery' =\u003e 'app\\models\\cms\\PageQuery',\n    ],\n],\n```\n\n- [Translations](https://github.com/NullRefExcep/yii2-core#translation-overriding):\n```php\n[\n /** App config **/\n 'components' =\u003e [\n  'i18n' =\u003e [\n      'translations' =\u003e [\n          '*' =\u003e ['class' =\u003e 'yii\\i18n\\PhpMessageSource'],\n          'cms' =\u003e ['class' =\u003e 'nullref\\core\\components\\i18n\\PhpMessageSource'],\n      ],\n  ],\n ]\n]\n```\n- [Views](http://www.yiiframework.com/doc-2.0/yii-base-theme.html#$pathMap-detail):\n\n```php\n/** App config **/\n'components' =\u003e [\n    'view' =\u003e [\n        'theme' =\u003e [\n            'pathMap' =\u003e [\n                '@nullref/cms/views' =\u003e '@app/views/cms'\n            ],\n        ],\n    ],\n],\n```\n- [Controllers](http://www.yiiframework.com/doc-2.0/guide-structure-controllers.html):\n\n```php\n/** module config **/\n'cms' =\u003e [\n    'class' =\u003e 'nullref\\cms\\Module',\n    'controllerNamespace' =\u003e 'app\\modules\\cms\\controllers',\n    'controllerMap' =\u003e [\n        // declares \"page\" controller using a class name\n        'page' =\u003e 'app\\controllers\\PageController',\n    ],\n],\n```\n\nAdmin Panel\n----------------------------\n\nYou can use this module with [Yii2 Admin](https://github.com/NullRefExcep/yii2-admin) module.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnullrefexcep%2Fyii2-cms","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnullrefexcep%2Fyii2-cms","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnullrefexcep%2Fyii2-cms/lists"}