Skip to content

Commit

Permalink
新增支持插件扩展中使用的控制器可以指定模板文件
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaobo.sun committed Oct 13, 2016
1 parent 8804cfc commit 8396832
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
24 changes: 22 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,23 @@ class Action
}
}
```
> 如果需要使用view模板则需要继承`\think\addons\Controller`
> 模板文件所在位置为插件目录的view中,规则与模块中的view规则一致
```
<?php
namespace addons\test\controller;
use think\addons\Controller;
class Action extends Controller
{
public function link()
{
return $this->fetch();
}
}
```

## 使用钩子
> 创建好插件后就可以在正常业务中使用该插件中的钩子了
Expand All @@ -140,14 +157,14 @@ class Action
### 模板中使用钩子

```
<div>{:hook('test', ['id'=>1])}</div>
<div>{:hook('testhook', ['id'=>1])}</div>
```

### php业务中使用
> 只要是thinkphp5正常流程中的任意位置均可以使用
```
hook('test', ['id'=>1])
hook('testhook', ['id'=>1])
```

## 插件目录结构
Expand All @@ -159,6 +176,9 @@ tp5
-- test
--- controller
---- Action.php
--- view
---- action
----- link.html
--- config.php
--- info.html
--- Test.php
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"homepage": "https://github.com/5ini99/think-addons",
"license": "Apache-2.0",
"minimum-stability": "stable",
"version": "1.0.3",
"version": "1.0.4",
"authors": [
{
"name": "xiaobo.sun",
Expand Down

0 comments on commit 8396832

Please sign in to comment.