5.0 Removing menu items from header bar

cancel
Showing results for 
Search instead for 
Did you mean: 
gregk
Member II

5.0 Removing menu items from header bar

Hi,

I'm trying to remove various menu items from the UI for non-admin users. I've created an extension as discussed in:
http://blogs.alfresco.com/wp/developer/2013/09/04/customizing-the-share-header-menu-part-1/

This extended the original ../webapps/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/share/header/share-header.get.js
with my removals in ../shared/classes/alfresco/web-extension/…/share-header.get.js

This worked fine for most pages…However this does not work for other pages like search.

I've since read: http://www.curiousnerd.me/alfresco-share-5-0-x-header-customization/

This suggests changing the include within the overridden share-header.get.js to include an additional customised version of share-header.<strong>lib</strong>.js (also in ../shared/).

Should I just be able to override share-header.lib.js so the original and override are called on any includes? - this doesn't seem to work.
Otherwise I'd have to copy the contents from the original share-header.lib.js and add my changes then override any *.get.js including the modified share-header.lib.js. - This didn't seem to work for me either.

Please could someone confirm the correct action for customising the menu header throughout all alfresco pages.

Thanks!
6 Replies
gregk
Member II

Re: 5.0 Removing menu items from header bar

I've managed to get around this in the short term by duplicating the contents of my modified share-header.get.js in an overridden version of faceted-search.get.js. My menu changes now appear on the faceted search as well as everywhere else. This isn't future proof though because as soon as any other pages/sections start to import the share-header.lib.js they'll have to be overridden too. Is there no easy way of overriding the lib.js ?

Thanks,
hardik1512
Established Member II

Re: 5.0 Removing menu items from header bar

ddraper
Intermediate

Re: 5.0 Removing menu items from header bar

The <alwaysApply> approach will work to address this problem (as described in the forum post lined by Hardik) - this is how we've implemented the extension in the Alfresco Cloud offering.
gregk
Member II

Re: 5.0 Removing menu items from header bar

Hi Both,

Thanks for the assistance, I've just been able to test this change but it doesn't seem to work. With the suggested changes my extension xml now looks like this:


<customization>
  <targetPackageRoot>org.alfresco.share.header</targetPackageRoot>
  <sourcePackageRoot>org.me.share.header</sourcePackageRoot>
</customization>
<customization>
  <targetPackageRoot>org.alfresco.share.pages</targetPackageRoot>
  <sourcePackageRoot>org.me.share.pages</sourcePackageRoot>
  <alwaysApply>
    <webscript>share-header</webscript>
  </alwaysApply>
</customization>


Note org/me/share/pages is now empty because I'm not overriding the facet search js (that does work but probably isn't future proof).
For the cloud offering you seem to be overriding the pages directory with the header one. EG:


<customization>
  <targetPackageRoot>org.alfresco.share.pages</targetPackageRoot>
  <sourcePackageRoot>org.alfresco.cloud.core.customizations.share.header</sourcePackageRoot>
  <alwaysApply>
    <webscript>share-header</webscript>
  </alwaysApply>
</customization>


Should I be overriding the facet search js file or do I just need for the share/pages directory to be over-ridden for the alwaysApply to take affect.

I'm just going to try another couple of tests…

Thanks
gregk
Member II

Re: 5.0 Removing menu items from header bar

I've got it working…

To summarise:

I created my own share-header.get.js with just my alterations and placed it in a tomcat shared location with the ending path defined in the extension xml

Original file:
../webapps/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/share/header/share-header.get.js
My file with just my customisations:
../shared/classes/alfresco/web-extension/…./me/share/header/share-header.get.js


<customization>
  <targetPackageRoot>org.alfresco.share.header</targetPackageRoot>
  <sourcePackageRoot>org.me.share.header</sourcePackageRoot>
</customization>


I then added an extension definition for the containing folder of the faceted-search.get.js but pointed this to the same source package as the share header path and set the alwaysApply option:


<customization>
  <targetPackageRoot>org.alfresco.share.header</targetPackageRoot>
  <sourcePackageRoot>org.me.share.header</sourcePackageRoot>
</customization>
<customization>
  <targetPackageRoot>org.alfresco.share.pages</targetPackageRoot>
  <sourcePackageRoot>org.me.share.header</sourcePackageRoot>
  <alwaysApply>
    <webscript>share-header</webscript>
  </alwaysApply>
</customization>


Note:
target: org.alfresco.share.<strong>pages</strong>
source: org.me.share.<strong>header</strong>

This does work ok and should cover any new pages/features that arrive in the share/pages folder.

Hopefully that helps someone else!
Apologies for posting this in the wrong discussion!..I guess I started with the mindset of assuming the menu would end user configurable…

Thanks for the help!