#608 Developer

Parent Category:
Documentation
Category:
DPAttachments
Last Updated:
Allon Moritz, Sunday, 29 September 2013 11:20 (Sunday, 29 September 2013)
Created:
Sunday, 29 September 2013 11:20 (Sunday, 29 September 2013)
Hits:
4741

Integrate into your extension

DPAttachments can be integrated easily into your existing Joomla extension, doesn't matter if it is a component, module or plugin. It takes just three lines of code.

if (JLoader::import('components.com_dpattachments.libraries.dpattachments.core', JPATH_ADMINISTRATOR)) {
    echo DPAttachmentsCore::render('com_demo.item', $object->id);
}

 Write your own plugin

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 DPAttachements. Basically you need the following code similar to the DPCalendar event plugin:

<?php
/**
 * @package		DPAttachments
 * @author		Digital Peak http://www.digital-peak.com
 * @copyright	Copyright (C) 2012 - 2013 Digital Peak. All rights reserved.
 * @license		http://www.gnu.org/licenses/gpl.html GNU/GPL
 */
defined('_JEXEC') or die();

JLoader::import('components.com_dpattachments.libraries.dpattachments.core', JPATH_ADMINISTRATOR);

// If the component is not installed we fail here and no error is thrown
if (! class_exists('DPAttachmentsCore')) {
    return;
}

class plgDPCalendarDpattachments extends JPlugin {

    public function onEventAfterDisplay($event, $output) {
        return DPAttachmentsCore::render('com_dpcalendar.event', $event->id);
    }

    public function onEventAfterDelete($event) {
        return DPAttachmentsCore::delete('com_dpcalendar.event', $event->id);
    }
}

 

Comments (0)

We use cookies on our website. Some of them are essential for the operation of the site, while others help us to improve this site and the user experience (tracking cookies). You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.