Introduction to Interface Extensions and Extension Points

User Interface Extensions (abbreviated as UIX) are used in order to provide a way to alter the content of existing interface elements. This functionality was added in version 4.2 and is documented in the UI Extension Module.

The main use case Interface Extensions try to fix is the need for applications (like Blog, Watchlist, etc.) to insert custom content in already existing interface components (like panels, menus, layout, etc.). 

Let's take an example: We developed an application called 'Hello World' and we want to provide a link to it inside the 'Applications' panel.
There are two questions that need to be answered: 

  • where we insert? - this is the Extension Point (UIXP)
  • what we insert? - this is the UI Extension (UIX)

About Extension Points

Extensions Points (UIXP) specify where the new content is about to be inserted. Is like a hoof defined in the interface where Interface Extensions are gathered.
For our example, we need to know the extension point ID for the 'Applications' panel. That is 'org.xwiki.platform.panels.Applications'.

There is a list of available extension points where we can add functionality, but we can also manually define new extension points.

About Interface Extensions

All the UIXs provided for a given Extension Point are displayed in that location.
For our example, if we want to add a new link in the 'Applications' panel, we need to create a new UIX that uses the 'org.xwiki.platform.panels.Applications' extension point. UIXs are stored as standard XObjects, instances of XWiki.UIExtensionClass. For our UIX we will need to provide the label, target and icon parameters, in order to be properly displayed in the panel.

Read the documentation on how to add an UIX inside the 'Applications' panel.

Adding your own Extension Point

Your UIExtension can define its own extension points, where other extensions can plug in. Here is an example of velocity code to include in your extension in order to make it an entry point for others:

  • Without parameters:
    #foreach ($extension in $services.uix.getExtensions(""))
      $services.rendering.render($extension.execute(), 'xhtml/1.0')
  • Display the parameters:
    #set ($extensions = $services.uix.getExtensions('', {'sortById' : ''}))
    #foreach ($extension in $extensions)
  • Test the parameter for a particular value:
    #foreach ($extension in $services.uix.getExtensions(""))
     #if ($extension.getParameters().get('parameter_name') == 'expected_value')

     {{html clean=false}}$services.rendering.render($extension.execute(), 'xhtml/1.0'){{/html}}
Created by Vincent Massol on 2017/09/05

Get Connected