pessek / pessek_attachments
File attachments for Elgg
Installs: 5
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:elgg-plugin
Requires
- php: >=7.4
- composer/installers: ^1.0.8
- pessek/acl_builder_api: ~4.0
Conflicts
- elgg/elgg: <4.0
This package is not auto-updated.
Last update: 2024-11-18 15:34:24 UTC
README
Features
- API and UI for attaching files and other entities
- Form input for uploading file attachments
- Views for displaying attachments
Usage
Magic
If you add your entity subtype to a list of entities supporting attachments, the plugin will attempt to create all of the UI, necessary to upload and display attachments:
elgg_register_plugin_hook_handler('allow_attachments', 'object:my_subtype', '\Elgg\Values::getTrue');
Note that this generic approach might not work with all plugins, and may require additional customizations on your side.
Display an attachment input
echo elgg_view('input/attachments');
To add an attachments input to your comment and discussion replies forms, use the following code. You will not need to add any code to your save action.
echo elgg_view('input/attachments', [ 'name' => 'comment_attachments', ]);
To add an attachments input to your personal messages and replies forms, use the following code. You will not need to add any code to your save action.
echo elgg_view('input/attachments', [ 'name' => 'message_attachments', ]);
Note that if you are not using hypeDropzone, your form must have it's encoding set to multipart/form-data
.
Attach uploaded files in an action
hypeapps_attach_uploaded_files($entity, 'upload', [ 'access_id' => $entity->access_id, // change the access level of uploaded files ]);
Attach an object
hypeapps_attach($entity, $attachment);
Display attachments
```php echo elgg_view('output/attachments', [ 'entity' => $entity, ]);