3

I would like to customize the share UI header, for example remove some of buttons such as People and Shared files. I found that this can be done by modifying the share-header.lib.js file located in the tomcat/webapps/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/share/imports folder. On modifying this file, I can see the changes. But as has been advised in these links: https://forums.alfresco.com/forum/developer-discussions/alfresco-share-development/correctbest-way-customize-shares-ui-07182011 http://ecmarchitect.com/archives/2010/09/07/1212

The right way would be to create the same folder structure under the tomcat/webapps/share/WEB-INF/classes/alfresco/web-extension directory and put the modified file there. I created the folder hierarchy and copied the share-header.lib.js file in this folder with the changes but now the changes are not seen on the website. Am I missing something ? Can anyone advise on the right method to do this ?

Thanks !

jcoder12
  • 167
  • 1
  • 4
  • 15
  • http://localhost:8081/share/page/modules/deploy .Its module deployment url.Create module and than update it byusing above url.Let me know if you face any issue. – Krutik Jayswal Oct 27 '14 at 19:33
  • Hi @KrutikJayswal, thanks for replying. I don't need to add a new module, just would like to disable two of the items from the header. Is there an easy to do that ? – jcoder12 Oct 27 '14 at 19:56
  • what version are we talking about? I'll flag this question with other in which I already answered this question for version 4.2. – Miki Oct 28 '14 at 08:36
  • 1
    possible duplicate of [How do I disable Alfresco main menu items?](http://stackoverflow.com/questions/24329850/how-do-i-disable-alfresco-main-menu-items) – Miki Oct 28 '14 at 08:36

2 Answers2

4

The general guideline that tomcat/webapps/share/WEB-INF/classes/alfresco/web-extension overrides tomcat/webapps/share/WEB-INF/classes/alfresco is correct but there is one big caveat: it only works for webscripts.

In your case there are two files involved in the generation of the header:

  • WEB-INF/classes/alfresco/site-webscripts/org/alfresco/share/header/share-header.get.js
  • WEB-INF/classes/alfresco/site-webscripts/org/alfresco/share/imports/share-header.lib.js

The former belongs indeed to a webscript (you'll find a share-header.get.desc.xml in the same directory). This file can be overridden by placing a file in a similar directory structure under WEB-INF/classes/alfresco/web-extension as you've correctly found in your research.

The latter however is not part of a webscript. Rather it is imported through an import directive. Importing is a completely different mechanism and the WEB-INF/classes/alfresco/web-extension trick doesn't work here.

The first lines of share-header.get.js clarify this:

<import resource="classpath:/alfresco/site-webscripts/org/alfresco/share/imports/share-header.lib.js">

model.jsonModel = {
   rootNodeId: "share-header",
   ...

The imported resource is loaded from the classpath literally, without any web-extension overlay. To import your customised version of share-header.lib.js, the first line should have been:

<import resource="classpath:/alfresco/web-extension/site-webscripts/org/alfresco/share/imports/share-header.lib.js">

So in summary my recommendation is to customise both header/share-header.get.js (just the first line) and imports/share-header.lib.js (as you've already done).

Remember that when you create a new customisation file it is safer to restart Alfresco. On the other hand when you edit an existing customisation file it is sufficient to visit /share/service/index on your local installation and click on Refresh Web Scripts and Clean Dependency Caches.

softwareloop
  • 383
  • 2
  • 5
2

Actually, your approach isn't the best one. As in Alfresco documentation you should configure your share-config-custom.xml in tomcat/shared/classes/web-extension folder. You should find a sample file there. Look for the original one share-config.xml in share webapp folder: and search for the <header> tag. It will look something similar to this:

<app-items>

        <!-- defaults: icon="{id}.png" label="header.{id}.label" description="header.{id}.description" -->

        <item type="link" id="my-dashboard">{userdashboardpage}</item>

        <item type="js" id="sites">Alfresco.module.Sites</item>

        <item type="link" id="people">/people-finder</item>

        <item type="link" id="repository" condition="conditionRepositoryRootNode">/repository</item>

        <item type="container" id="more">

           <container-group id="my">

              <item type="link" id="my-tasks">/my-tasks</item>

              <item type="link" id="my-workflows">/my-workflows</item>

              <item type="link" id="my-content">/user/user-content</item>

              <item type="link" id="my-sites">/user/user-sites</item>

              <item type="link" id="my-profile">{userprofilepage}</item>

           </container-group>

           <container-group id="tools" permission="admin">

              <item type="link" id="application">/console/admin-console/application</item>

              <item type="link" id="groups">/console/admin-console/groups</item>

              <item type="link" id="replication-jobs" condition="!conditionEditionTeam">/console/admin-console/replication-jobs</item>

              <item type="link" id="repository">/console/admin-console/repository</item>

              <item type="link" id="trashcan">/console/admin-console/trashcan</item>

              <item type="link" id="users">/console/admin-console/users</item>

              <item type="link" id="more">/console/admin-console/</item>

           </container-group>

        </item>

     </app-items>

Copy the entire section in your share-config-custom.xml file. make your changes and restart Alfresco. You should be good to go.

Teqnology
  • 1,282
  • 8
  • 20
  • 2
    The "app-items" approach used to be the correct one until version 4.2.d but is now deprecated. Recent versions (4.2.e, 4.2.f, 5.0.x) use Aikau, Share's new UI framework. The original question refers to share-header.lib.js which uses this new approach. – softwareloop Oct 28 '14 at 08:48