Skip to content

Commit

Permalink
define custom script viewBlock + update Readme
Browse files Browse the repository at this point in the history
  • Loading branch information
passchn committed Oct 29, 2023
1 parent 3e3303d commit a2b03d0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ Use the `FilePool` helper for any Entity in a template:
) ?>
```

### Define relations

You can easily define Relations to the entity in your `ExamplesTable`:

```php
Expand All @@ -71,6 +73,19 @@ $this->hasMany('Downloads', ['foreignKey' => 'owner_id'])

… and then access the files through `$example->downloads` after containing `Downloads.Assets` in your Controller.

### Rendering the Widget

If the widget does not show up, make sure you are fetching scripts somewhere in your template:

```php
<?= $this->fetch('script') ?>
```

You can change the viewBlock the plugin is using via the `'FilePool.ViewBlock'` config, e.g. in your `app.php`.

> [!IMPORTANT]
> Scripts should be fetched at the end of your html. Styles will be loaded via JavaScript.
## Contribution

You are welcome to open Issues or Pull Requests.
5 changes: 4 additions & 1 deletion templates/element/helper/FilePool.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@
],
// url of the vite dev server
'url' => 'http://localhost:3001',
]
],
'viewBlocks' => [
'script' => \Cake\Core\Configure::read('FilePool.ViewBlock', 'script'),
],
]));

?>
Expand Down

0 comments on commit a2b03d0

Please sign in to comment.