Hi,
On 3 Feb 2016 at 11:24:22, Gerritjan Koekkoek
(gerritjan@cdlsworld.org(mailto:gerritjan@cdlsworld.org)) wrote:
Hi,
We have pages having ONE UIExtension objects of XWiki.UIExtensionClass.
Using as
$services.uix.getExtensions('dashboard.mainMenu.items',{'sortByParameter'
: 'displayorder'})
With a #foreach loop we can access all the parameters. (and other extension properties)
But is it possible to get the page information (Name, Title, Creator, Rights)
The use case is that we want a dynamic menu based on that information?
The following did not give the desired result:
#set($dashboardMenuItems =
$services.uix.getExtensions('dashboard.mainMenu.items',{'sortByParameter'
: 'displayorder'}) )
#foreach($dashboardMenuItem in $dashboardMenuItems)
#set($dashboardMenuItemDocument = $xwiki.getDocument($dashboardMenuItem))
#end
I guess you already know
about
http://extensions.xwiki.org/xwiki/bin/view/Extension/UIExtension+Module ?
$services.uix.getExtensions returns a List<UIExtension> and UIExtension is:
public interface UIExtension
{
/**
* @return the ID of this extension
*/
String getId();
/**
* @return the ID of the extension point this UI extension is providing an extension
for
*/
String getExtensionPointId();
/**
* A map of parameters provided by the extension. When providing a new Extension Point
the developer must document
* the list of parameters he requires.
*
* @return a map of parameters provided by the extension
*/
Map<String, String> getParameters();
/**
* @return the {@link Block} that must be rendered when this extension is displayed
*/
Block execute();
}
So as you can see there’s no way to return anything else here.
However, when you define your UIX you can pass any number of parameters (which are
retrieved through calling getParameters() on UIExtension).
So you could have params like:
name = $doc.documentReference (or $doc.fullName)
title = $doc.title
creator = $doc.creatorReference
hasAdmin = $services.authorization.checkAccess(‘ADMIN’, $doc.authorReference)
...
Hope it helps,
-Vincent
Gerritjan Koekkoek
Vader van Rai Koekkoek (cdls) en voorzitter vereniging CdLS
Visit our website
Facebook
email