Skip to content

Commit fcd4c48

Browse files
Update README
1 parent 5b297fe commit fcd4c48

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# Kirby Snippet Controller
2-
Define snippet controllers in a similar way how page controllers work.
2+
Define snippet controllers in a similar way to how page controllers work.
3+
4+
## How to use it
35
By default the plugin will try to find controllers in your `snippets` directory.
46
Lets have a look at a example `header` snippet.
57

6-
## How to use it
78
```bash
89
📁 snippets
910
├─ 📄 header.controller.php
@@ -27,7 +28,7 @@ return [
2728

2829
```
2930

30-
You can also define controllers in a plugin.
31+
You can also define snippet controllers in a plugin.
3132
```php
3233
Kirby::plugin('superwoman/superplugin', [
3334
'snippets' => [
@@ -52,7 +53,11 @@ Kirby::plugin('superwoman/superplugin', [
5253
```
5354

5455
### Available callback arguments in your controllers
55-
Like in regular controllers, you can access the `$site`, `$page`, `$pages` and `$kirby` objects by loading them as arguments to the anonymous function. The plugin will inject the right objects for you. In addition, you also have access to the `$data` argument, which contains the data you passed to the snippet.
56+
Like in regular controllers, you can access the `$site`, `$page`, `$pages` and `$kirby` objects by loading them as arguments to the anonymous function. The plugin will inject the right objects for you. In addition, you also have access to the `$data` argument, which is the array of data you passed to the snippet.
57+
58+
```php
59+
<?php snippet('header', data: ['title' => 'My Title']) ?>
60+
```
5661

5762
### Naming convention
5863
By default, the plugin searches for controllers by appending `.controller` to the snippet name. You can change the name resolver in the options. Changing the name also affects plugin-defined controllers.

0 commit comments

Comments
 (0)