Skip to content

Commit

Permalink
Пример компонента для генерации плагина
Browse files Browse the repository at this point in the history
  • Loading branch information
mzhelskiy committed Apr 16, 2017
1 parent d8082f1 commit fe79575
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function RegisterHook()
* Хук на старте экшенов. Выполняется один раз в отличии от хука "init_action"
* Четвертый параметр 1000 - это приоритет выполнение среди остальных навешанных хуков (чем больше, тем раньше будет выполнен обработчик)
*/
//$this->AddHook('start_action','HookStartAction', __CLASS__, 1000);
$this->AddHook('start_action', 'HookStartAction', __CLASS__, 1000);
}

/**
Expand All @@ -36,4 +36,12 @@ public function HookTopicEditAfter($aParams)
$oTopic = $aParams['oTopic'];

}

public function HookStartAction($aParams)
{
/**
* Регистрируем компонент плагина (позволяет автоматически подгружать его css/js)
*/
$this->Component_Add('example:p-test');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{component_define_params params=[ 'number' ]}

Контент блока из компонента: {$number}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "p-test",
"version": "1.0.0",
"templates": {
"bar": "bar.tpl"
},
"scripts": {
"foo": {
"file": "js/foo.js",
"merge": true
}
},
"styles": {
"foo": "css/foo.css"
}
}
Empty file.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*}

{capture 'block_content'}
Содержание блока
{component 'example:p-test' template='bar' number=1234}
{/capture}

{component 'block'
Expand Down

0 comments on commit fe79575

Please sign in to comment.