From 901eafecfa2515a7752f45b2af7efba00b5a4449 Mon Sep 17 00:00:00 2001 From: Yuri Salimovskiy Date: Wed, 18 Jan 2023 17:23:11 +0200 Subject: [PATCH 1/3] dev docs on using filemanager with fieldtypes (cherry picked from commit c39a9980d7e690e3cd315bf0ce485fa0fe1dc490) --- docs/development/fieldtypes/enhanced.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/development/fieldtypes/enhanced.md b/docs/development/fieldtypes/enhanced.md index ddbe527af..eed2f4fb8 100644 --- a/docs/development/fieldtypes/enhanced.md +++ b/docs/development/fieldtypes/enhanced.md @@ -239,6 +239,16 @@ Possible return values are: - `'text'` - shows text input - `'select'` - shows select input populated with the field options (for fieldtypes that extend `OptionFieldtype`) +## File Manager support + +References to files (as placed by Filepicker) can be in different forms - contaning file ID (e.g. `{file:123:url}`), or contaning directory ID and file name (e.g. `{filedir_2}filename.jpg`) when in [Compatibility Mode](control-panel/file-manager/file-manager.md#compatibility-mode). + +To get both cases parsed correctly, please use `ee()->file_field->parse_string` function. + + ee()->load->library('file_field'); + $data = ee()->file_field->parse_string($data); + +If you fieldtype is using custom JavaScript for treating the files, be sure to make the code aware of [`EE.fileManagerCompatibilityMode`](development/control-panel-js/globals.md#filemanagercompatibilitymode) variable. ## Implementing Filepicker for Rich Text Editor From e005458677b68c7ff33c2ebb3c370433b40631e9 Mon Sep 17 00:00:00 2001 From: Tom Jaeger Date: Fri, 3 Feb 2023 14:58:40 -0500 Subject: [PATCH 2/3] Update enhanced.md Few updates to the file picker content. --- docs/development/fieldtypes/enhanced.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/development/fieldtypes/enhanced.md b/docs/development/fieldtypes/enhanced.md index eed2f4fb8..4e57bbecc 100644 --- a/docs/development/fieldtypes/enhanced.md +++ b/docs/development/fieldtypes/enhanced.md @@ -241,9 +241,9 @@ Possible return values are: ## File Manager support -References to files (as placed by Filepicker) can be in different forms - contaning file ID (e.g. `{file:123:url}`), or contaning directory ID and file name (e.g. `{filedir_2}filename.jpg`) when in [Compatibility Mode](control-panel/file-manager/file-manager.md#compatibility-mode). +References to files in content (ex. when a file is selected by the Filepicker) can be in two different forms, depending on if the file manager is running in Compatibility Mode or not. If it's not running in compatibility mode, the file references in content will contain a file ID (e.g. `{file:123:url}` where 123 is the file id). The file can also be referenced in content with a directory ID and file name (e.g. `{filedir_2}filename.jpg`) when in [Compatibility Mode](control-panel/file-manager/file-manager.md#compatibility-mode). -To get both cases parsed correctly, please use `ee()->file_field->parse_string` function. +To parse both cases correctly, please use `ee()->file_field->parse_string` function. ee()->load->library('file_field'); $data = ee()->file_field->parse_string($data); From 1167ab287d93eca32de4aa80230e35d4b0fd6e7a Mon Sep 17 00:00:00 2001 From: Matt Johnson Date: Fri, 3 Feb 2023 15:01:26 -0600 Subject: [PATCH 3/3] Update enhanced.md --- docs/development/fieldtypes/enhanced.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/development/fieldtypes/enhanced.md b/docs/development/fieldtypes/enhanced.md index 4e57bbecc..2617bdc5b 100644 --- a/docs/development/fieldtypes/enhanced.md +++ b/docs/development/fieldtypes/enhanced.md @@ -241,14 +241,14 @@ Possible return values are: ## File Manager support -References to files in content (ex. when a file is selected by the Filepicker) can be in two different forms, depending on if the file manager is running in Compatibility Mode or not. If it's not running in compatibility mode, the file references in content will contain a file ID (e.g. `{file:123:url}` where 123 is the file id). The file can also be referenced in content with a directory ID and file name (e.g. `{filedir_2}filename.jpg`) when in [Compatibility Mode](control-panel/file-manager/file-manager.md#compatibility-mode). +When a file is referenced inside content, it can be in two different forms depending on if the file manager is running in compatibility mode or not. An example of this is when a file is chosen inside an RTE field via the filepicker. If the file manager is not running in [compatibility mode](control-panel/file-manager/file-manager.md#compatibility-mode), the file references in content will contain a file ID (e.g. `{file:123:url}` where 123 is the file ID). The file can also be referenced in content with a directory ID and file name (e.g. `{filedir_2}filename.jpg`) when in compatibility mode. -To parse both cases correctly, please use `ee()->file_field->parse_string` function. +To parse both cases correctly, please use the `ee()->file_field->parse_string()` function. ee()->load->library('file_field'); $data = ee()->file_field->parse_string($data); -If you fieldtype is using custom JavaScript for treating the files, be sure to make the code aware of [`EE.fileManagerCompatibilityMode`](development/control-panel-js/globals.md#filemanagercompatibilitymode) variable. +If the fieldtype is using custom JavaScript for manipulating the files, be sure to make the code aware of the [`EE.fileManagerCompatibilityMode`](development/control-panel-js/globals.md#filemanagercompatibilitymode) variable. ## Implementing Filepicker for Rich Text Editor