custom share-header

cancel
Showing results for 
Search instead for 
Did you mean: 
ALfreSara
Active Member

custom share-header

Jump to solution

Hello

I tried to override the getSiteData() in the share-header.lib.js file. I created the modified share-header.get.js in the following directory of SDK folder sites-webscripts/

sites-webscripts/com/alfresco/share/header/

and my extension file is like as follow

<module>

<id>custom shareService</id>

<version>1.0</version>

<auto-deploy>true</auto-deploy>

<customizations>

<customization>

<targetPackageRoot>org.alfresco.share.header</targetPackageRoot>

<sourcePackageRoot>com.alfresco.share.header</sourcePackageRoot>


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

</customizations>

</module>


My file:share-header.get.js

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

model.jsonModel = {
rootNodeId: "share-header",
services: getHeaderServices(),
widgets: [
{
id: "SHARE_VERTICAL_LAYOUT",
name: "alfresco/layout/VerticalWidgets",
config:
{
widgets: getHeaderModel()
}
}
]
};

getSiteData(){
...
}

 

But the changes made are not supported. Do I need to add anything more?


Thanks.

1 Solution

Accepted Solutions
abhinavmishra14
Advanced

Re: custom share-header

Jump to solution

Can you explain what you are trying to achieve, there might be a better way to do it.

However, following your comments, If you are following documentation:

https://docs.alfresco.com/5.2/tasks/dev-extensions-share-tutorials-custom-share-header-menu.html

https://docs.alfresco.com/5.2/concepts/dev-extensions-share-override-ootb-surf-webscripts.html

And If you are extending share header menu, items etc., this should be enough to extend them. 

<module>
	<id>custom shareService</id>
	<version>1.0</version>
	<auto-deploy>true</auto-deploy>
	<customizations>
		<customization>
		  <!-- extension for share header -->
		  <targetPackageRoot>org.alfresco.share.header</targetPackageRoot>
		  <sourcePackageRoot>com.alfresco.share.header</sourcePackageRoot>
		</customization>
	</customizations>
</module>

Since you are trying to extend the 'share-header.lib.js', it can't be done via 'customization' (extension module). The 'customisation' does post-processing which is used to add/update the result of the ootb webscripts and it is targetted to extend webscripts not a library.

Use: widgetUtils.findObject(model.jsonModel, "id", "ID") instead to modify/update any existing widgets.

 

In worst case, if you have to make changes in 'share-header.lib.js' then it needs to be copied in web-extension directory as: /alfresco/web-extension/site-webscripts/org/alfresco/share/imports/share-header.lib.js

Also copy the original share-header.get.js to the path: /alfresco/web-extension/site-webscripts/org/alfresco/share/header/share-header.get.js

Update the 'share-header.get.js' import statement:

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

This may work and any changes made to share-header.lib.js may be visible. Also you won't need 'customization' (i.e. no need of creating the extension module as done above). I wouldn't recommend doing this though because it is not correct approach for future upgrades. 

Extension modules keeps your custom changes isolated from OOTB changes.

 

~Abhinav
(ACSCE, AWS SAA, Azure Admin)

View solution in original post

2 Replies
ALfreSara
Active Member

Re: custom share-header

Jump to solution

Any help please

abhinavmishra14
Advanced

Re: custom share-header

Jump to solution

Can you explain what you are trying to achieve, there might be a better way to do it.

However, following your comments, If you are following documentation:

https://docs.alfresco.com/5.2/tasks/dev-extensions-share-tutorials-custom-share-header-menu.html

https://docs.alfresco.com/5.2/concepts/dev-extensions-share-override-ootb-surf-webscripts.html

And If you are extending share header menu, items etc., this should be enough to extend them. 

<module>
	<id>custom shareService</id>
	<version>1.0</version>
	<auto-deploy>true</auto-deploy>
	<customizations>
		<customization>
		  <!-- extension for share header -->
		  <targetPackageRoot>org.alfresco.share.header</targetPackageRoot>
		  <sourcePackageRoot>com.alfresco.share.header</sourcePackageRoot>
		</customization>
	</customizations>
</module>

Since you are trying to extend the 'share-header.lib.js', it can't be done via 'customization' (extension module). The 'customisation' does post-processing which is used to add/update the result of the ootb webscripts and it is targetted to extend webscripts not a library.

Use: widgetUtils.findObject(model.jsonModel, "id", "ID") instead to modify/update any existing widgets.

 

In worst case, if you have to make changes in 'share-header.lib.js' then it needs to be copied in web-extension directory as: /alfresco/web-extension/site-webscripts/org/alfresco/share/imports/share-header.lib.js

Also copy the original share-header.get.js to the path: /alfresco/web-extension/site-webscripts/org/alfresco/share/header/share-header.get.js

Update the 'share-header.get.js' import statement:

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

This may work and any changes made to share-header.lib.js may be visible. Also you won't need 'customization' (i.e. no need of creating the extension module as done above). I wouldn't recommend doing this though because it is not correct approach for future upgrades. 

Extension modules keeps your custom changes isolated from OOTB changes.

 

~Abhinav
(ACSCE, AWS SAA, Azure Admin)