Using menu data sources, for instance getMenu, getMenuBranch or getSubMenu, is there a way to get the name of the page template used for each menu item?
Using the same data sources, there are attributes owner and modifier for each menu item. How to map those hashed values / ids to users from the user store? I would like to know the username or display name of that user.
Sebjørn Rundereim Birkeland
I am afraid I must disappoint you on both questions here. At least for data sources. There are no data source that can help you with this information.
As far as finding the name of the page template, there is no way you can do that at all, through the portal. I guess we just never thought any developer might need that, so the only way of getting that information is by connecting straight to the database and using direct SQL, which I would not really recommend.
To get information about the user, there is a solution: Try using the Java API in a plugin: http://repo.enonic.com/public/com/enonic/cms/cms-api/4.7.17/cms-api-4.7.17-javadoc.jar!/index.html - If you create a function library with your custom methods, these may be called from the data sources and give you access to the information needed in XSL.
The function you create, can use a
com.enonic.cms.api.client.Client, normally in the form of a
RemoteClient, which has methods for
getUsers. These will return all the information you need about the users you ask for.
Hopefully that is at least of some help for you.
From what I remember, the getMenuItem datasource also outputs the page template name, but it can only retrieve data for a single menu item at a time.
Bjørnar is right here. The
getMenuItem data source returns an XML that includes a line like this:
<page key="18" pagetemplatekey="4" pagetemplate="Document" pagetemplatetype="5" />
This is the same for both Java API and data sources.
So, I guess the recommendation is to create a Function Library where you fetch the menu Item through the Java API (RemoteClient), parse the XML to find the users and look them up through the same Remote Client. Then put together a custom XML that you return to the data source and use in your XSL.
Thank you for your response. Our use case is actually not for developers, but for super users / editors. They wanted an easy way to know certain information about the site / menu items. The page template being used, as well as the user which created/modified it could be useful.
We might try the plugin-solution, given that this is important enough for us to invest the extra few hours developing the plugin.