From a2b03d076442960aa98c117f8063135e494ca378 Mon Sep 17 00:00:00 2001 From: passchn <77938819+passchn@users.noreply.github.com> Date: Sun, 29 Oct 2023 18:36:31 +0100 Subject: [PATCH] define custom script viewBlock + update Readme --- README.md | 15 +++++++++++++++ templates/element/helper/FilePool.php | 5 ++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fd696d3..f55a6d5 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 +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. diff --git a/templates/element/helper/FilePool.php b/templates/element/helper/FilePool.php index 9472d60..5444bc4 100644 --- a/templates/element/helper/FilePool.php +++ b/templates/element/helper/FilePool.php @@ -25,7 +25,10 @@ ], // url of the vite dev server 'url' => 'http://localhost:3001', - ] + ], + 'viewBlocks' => [ + 'script' => \Cake\Core\Configure::read('FilePool.ViewBlock', 'script'), + ], ])); ?>