Difference between revisions of "AppSuite:Writing a portal plugin"

(Where and how we start)
(Replaced content with "The content on this page has moved to https://documentation.open-xchange.com/latest/ui/customize/portal-widget.html Note: Open-Xchange is in the process of migrating all...")
 
(43 intermediate revisions by 9 users not shown)
Line 1: Line 1:
<div class="title">Writing a portal plugin</div>
+
The content on this page has moved to https://documentation.open-xchange.com/latest/ui/customize/portal-widget.html
  
'''Summary:''' This articles covers how to write a plugin that shows on the portal page. A portal plugin always gives a short overview on a piece of information (the so-called 'tile'). It can link a longer view that is opened when the tile is clicked, this we call the side pop-up. The side pop-up is optional.
+
Note: Open-Xchange is in the process of migrating all its technical documentation to a new and improved documentation system (documentation.open-xchange.com). Please note as the migration takes place more information will be available on the new system and less on this system. Thank you for your understanding during this period of transition.
 
 
== Where and how we start ==
 
Plugins are collected in the folder ui/apps/plugins. Create your new plugin there: Create a folder and in this folder, create two files: register.js (where everything happens) and manifest.json
 
 
 
== The simplest portal plugin: An advertisement ==
 
The simplest portal plugin comes without a side pop-up and shows static content on its tile. Two uses for this would be presenting an advertisement (or your daily creed, an often used check list....) or showing a link list (for example to other parts of an company's intranet that are not integrated into the AppSuite (yet)). We will now build an advertisement, which is just a slogan.
 
 
 
The beauty of this is that we do not have any dependencies (for example needing another module like the file store), so the content of our manifest.json is rather simple:
 
 
 
<pre class="language-javascript">
 
{
 
namespace: "portal"
 
}
 
</pre>
 
 
 
Nothing to see here. We say we belong in the portal namespace and that's it. We do not need to define any dependencies on other modules.
 
 
 
Our register.js is only slightly longer:
 
 
 
<pre class="language-javascript">
 
define("plugins/portal/myAd/register", ['io.ox/core/extensions'], function (ext) {
 
 
 
    "use strict";
 
 
 
    ext.point('io.ox/portal/widget/myAd').extend({
 
        preview: function () {
 
            var content = $('<div class="content">').text("Buy stuff. It's like solid happiness.");
 
            this.append(content);
 
        }
 
    });
 
 
 
    ext.point('io.ox/portal/widget/myAd/settings').extend({
 
        title: 'My advertisement',
 
        type: 'myAd'
 
    });
 
});
 
</pre>
 
 
 
So what do we have here? We have two extension points:
 
 
The first one is for the ad itself, ''io.ox/portal/widget/myAd''. This one contains a single method that we implement, ''preview''. ''Preview'' is responsible for the tile you see whenever you look at your portal. Technically, ''this'' contains the container to which you can attach your content. If you are brave, you can do changes on the container, too. But that is not needed for now.
 
 
 
The second is less obvious: It creates an option in the settings area for the portal (the one you reach by "customize this page"). There you will have to enable your setting. The ''title'' is what is shown as the name of your plugin (so chose a readable one), the type references the one you used in the definition.
 
 
 
== A typical portal plugin ==
 
A typical portal plugin uses the tile to display a short summary or teaser of its contents and uses a side-popup to show the whole content.
 
 
 
== Special switches ==
 
* unique
 
* unmovable
 
 
 
== Finishing touches ==
 
Now that you have learned all there is about portal plugins, it is time to clean up. Have you removed the plugin from DEV_PLUGINS? Good. Maybe we can interest you in [[AppSuite:i18n |  preparing the text for readers from other countries]]? Splendid! Now you are good to go.
 
 
 
[[Category:AppSuite]]
 
[[Category:UI]]
 

Latest revision as of 09:37, 22 May 2017

The content on this page has moved to https://documentation.open-xchange.com/latest/ui/customize/portal-widget.html

Note: Open-Xchange is in the process of migrating all its technical documentation to a new and improved documentation system (documentation.open-xchange.com). Please note as the migration takes place more information will be available on the new system and less on this system. Thank you for your understanding during this period of transition.