@@ -20,3 +20,74 @@ or add
2020```
2121
2222to the require section of your ` composer.json ` file.
23+
24+ Then You have run console command for install this module:
25+
26+ ```
27+ php yii module/install product
28+ ```
29+
30+ and module will be added to your application config (` @app/config/installed_modules.php ` )
31+
32+ Concept
33+ -------
34+
35+ This module allows you to build dynamic pages which consist of blocks (widget with config).
36+ You can create own type of widgets and register it in BlockManager.
37+
38+
39+ BlockManager
40+ ------------
41+
42+ This component contains information about available blocks.
43+ You can override it:
44+
45+ ``` php
46+ 'cms' => [
47+ 'class' => 'nullref\\cms\\Module',
48+ 'blockManagerClass' => 'app\components\BlockManager',
49+ ],
50+ ```
51+
52+ and add in your class own blocks:
53+
54+ ``` php
55+ class BlockManager extends BaseBlockManager
56+ {
57+ public function getList()
58+ {
59+ return array_merge([
60+ 'smile' => 'app\blocks\smile', //namespace of block files
61+ ], parent::getList());
62+ }
63+ }
64+ ```
65+
66+ Also you can register your block in runtime:
67+
68+ ``` php
69+ Block::getManager()->register('smile','app\blocks\smile');
70+ //or
71+ \Yii::$app->getModule($moduleId)->get('blockManager')->register('smile','app\blocks\smile');
72+ ```
73+
74+
75+
76+ Block structure convention
77+ --------------------------
78+
79+ Each valid block it's folder with to classes:
80+
81+ - Block - define data block to use
82+ - Widget - run with data when this block use on page
83+
84+ In most cases where is form file in this folder.
85+
86+ When you add own block you have to set unique id and namespace of block files folder.
87+
88+
89+
90+ Using with yii2-admin module
91+ ----------------------------
92+
93+ You can use this module with [ Yii2 Admin] ( https://github.com/NullRefExcep/yii2-admin ) module.
0 commit comments