cancel
Showing results for 
Search instead for 
Did you mean: 

understanding sites.get.js and modifying

jaspervlb
Champ in-the-making
Champ in-the-making
Hi

I'm am trying to customize the alfresco header (4.2). First I want to try and modify the dropdown to list all sites the logged in user is a member of. Later on I can then modify the header to be a menu bar with different icons for each site.

Now I understand I have to edit sites.get.js in the header module. I also found this topic on the forum: http://forums.alfresco.com/forum/end-user-discussions/alfresco-share/modify-favorite-sites-dropdown-...
but it is outdated. The code has changed already.

Can someone help me understand what happens?
<javascript>   // can optionally pass JSON list of fav sites if they are already known to the caller
   if (args.favsites)
   {
      favourites = eval('(' + args.favsites + ')');
   }</javascript>
When is this if-loop executed. When will this argument be passed? Is it a GET argument and will I see it in the address bar?

<javascript>
      prefs = eval('(' + preferences.value + ')');

      // Populate the favourites object literal for easy look-up later
      favourites = eval('try{(prefs.' + PREF_FAVOURITE_SITES + ')}catch(e){}');
</javascript>
What does this piece of code do? I can not find explanations in the javascript API's. Am I looking in the wrong place? Where can I find documentation on this prefs object. So I can see how to modify <javascript>const PREF_FAVOURITE_SITES = "org.alfresco.share.sites.favourites";</javascript> to list all sites.

<javascript>
   var connector = remote.connect("alfresco");
   result = connector.post("/api/sites/query", jsonUtils.toJSONString(query), "application/json");
</javascript>

Also I could not find documentation on this sites/query possibility. How can I find what queries are possible and how I need to format them.

Thanks!

1 REPLY 1

ddraper
World-Class Innovator
World-Class Innovator
It looks like you might have solved your problem on the forum post you've linked… but I just wanted to ask what version of Alfresco you're ultimately going to be targeting. You've said you're working on 4.2 but I'm wondering if this is based on the current nightly builds or from one of the community releases last year. The header bar (including the sites menu) has had quite an overhaul (although it's still possible to get the old header back) and you might find that the header bar is easier to customize and that it already provides something closer to your requirements already.

The new sites menu features the most recent sites visited (it still has the favourites in a cascade) as this is actually a more common requirement. It can be configured to show as many recent sites as you like (5 is the default). Even if this doesn't meet your requirements you might find that the new header bar is easier to customize.

If you're an Enterprise customer then what you're doing sounds like it will work on 4.1.x but you might want to wait for 4.2 Enterprise later this year… and if you're a Community user you may also want to check out the nightly builds or check out the latest code as the next Community release will have a different header bar.

As I said though, it is relatively easy to get the old header bar back if you prefer it.