DPAttachments can be integrated easily into your existing Joomla extension, doesn't matter if it is a component, module or plugin. Just write the following line in a view file and DPAttachments does the rest. The $app is sometimes not available, then you can use Joomla\CMS\Factory::getApplication.
echo $app->bootComponent('dpattachments')->render('com_demo.item', $object->id);
If you are not the developer of a Joomla extension but you want to integrate DPAttachments into it then you can write your own plugin. The only requirement is that the extensions fires an event where the plugin can be an observer of. Have a look at the content plugin of DPAttachments as example, it integrates into the common content events. Basically you need the following code when there is an component com_awesomeimages with an entity image:
class AwesomeImages extends CMSPlugin { /** @var CMSApplication $app */ protected $app; public function onImageAfterDisplay($image) { return $this->app->bootComponent('dpattachments')->render('com_awesomeimages.image', $image->id); } }
DPAttachments itself is extendable, there are the following plugin events where a plugin developer can listen to and interact accordingly. These are Joomla 4 events, so there is only one argument, a Joomla\Event\Event object which contains different arguments. Some of them do use the arguments for further processing, so the functions which are listening to the events should not return anything.
Description
Before the list of attachments is processed.
Arguments
Description
After the list of attachments is processed.
Arguments
Description
Before a layout is rendered in the DPAttachments context.
Arguments
Description
After a layout is rendered in the DPAttachments context.
Arguments
Description
When a permission is checked. After the event is dispatched and it contains an argument allowed which is true, then it dows not further processing to check the permissions of an item.
Arguments
Comments (0)