AnsweredAssumed Answered

Get instance of the siteService object

Question asked by gilleslesire on Nov 3, 2015
Latest reply on Nov 4, 2015 by gilleslesire
I have no experience with Alfresco, I do know how to program however, so no problem there.

I am trying to do a minor edit to the /share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/share/imports/share-header.lib.js file to add a few menu elements to the share menu.

I want to list all the sites a user is a member of.

After doing some searching I came across the siteService object which can do what I want to achieve so I added the following to the generateAppItems function.

<javascript>
function generateAppItems() {
…..
var sites = siteService.listUserSites(user.name);
   for (var i=0; i<sites.length; i++)
   {
       var targetUrl = "/share/page/site/" + sites.shortName + "/" + dashboard;
       appItems.push({
          id: "HEADER_SITE_" + sites.shortName.toUpperCase(),
          name: "alfresco/menus/AlfMenuBarItem",
          config: {
             id: "HEADER_SITE_" + sites.shortName.toUpperCase(),
             label: (sites.title) ? sites.title : sites.shortName,
             targetUrl: targetUrl
          }
       });
   }
…..
}
</javascript>

I try to get the sites the user is member of by using siteService.listUserSites(user.name). But now I get the following error

ReferenceError: "siteService" is not defined.


I have googled around but can't find anywhere how I should instantiate this elusive siteService object.

Outcomes