Hyperlink in custom property

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

Hyperlink in custom property

Hi,

i have a custom type with some properties (text). I need to add one more property with an hyperlink to another document in documentLibrary.

I know that i link folders using "Copy To -> Create Link", but in this case the link to document is only in folder. I want to create cliccable-hyperlink to related documents inside every documents.

There is a way to do this?

Thanks

1 Reply
abhinavmishra14
Advanced

Re: Hyperlink in custom property

Its not quite clear about the requirement, but If your requirement is that, you have a custom property and you just want to add link manually as a text and want to show it as link on the view details page, you can try below config:

<field id="demo:xyzprop">
	<control template="/org/alfresco/components/form/controls/textfield.ftl">
		<control-param name="activateLinks">true</control-param>
	</control>
</field>

Link should be activated on mouse hover and you should be able to click it. Note that, it wont display as link by default unless you mouse hover and text color remains default unlinke usual links.

If you have strict need to show the link with blue color and underline, you have to update the out of the box template (create a copy of template at your module level and use it in share form config) and add styling, for example:

<#assign fieldValue=field.value?html?replace("((http|ftp|https):\\/\\/[\\w\\-_]+(\\.[\\w\\-_]+)+([\\w\\-\\.,@?\\^=%&:\\/~\\+#]*[\\w\\-\\@?\\^=%&\\/~\\+#])?)", "<a href=\"$1\" target=\"_blank\" style=\"color: blue;text-decoration: underline;\">$1</a>", "r")>

If you want to show hyperlink on copied file to its original file. If that is the case, you can use the "cm:copiedfrom" aspect. This aspect is by default applied to the copied file and adding below given share config would show the link to original doc.

<config evaluator="aspect" condition="cm:copiedfrom">
	<forms>
		<form>
			<field-visibility>
				<show id="cm:original" />
			</field-visibility>
			<appearance>
				<!-- Applies a CSS (panel) before input fields. -->
				<set id="copied-from" appearance="panel" label-id="set.copied-from.label" />
				<field id="cm:original" set="copied-from" label-id="field.original.label" read-only="true">
					<control template="/org/alfresco/components/form/controls/association.ftl">
						<control-param name="displayMode">items</control-param>
						<control-param name="showTargetLink">true</control-param>
					</control>
				</field>
			</appearance>
		</form>
	</forms>
</config>

If you are creating association and want to show the associated files as a link, then similarly you can use following config example:

<config evaluator="node-type" condition="demo:doc">
	<forms>
		<form>
			<field-visibility>
				<show id="demo:relatedDocs"/>
				.....
			</field-visibility>
			<appearance>
				....
				
				<field id="demo:relatedDocs" label-id="Related Docs">
					<control template="/org/alfresco/components/form/controls/association.ftl">
						<control-param name="displayMode">items</control-param>
						<control-param name="showTargetLink">true</control-param>
					</control>
				</field>
			</appearance>
		</form>
		..
	</forms>
</config>

 

~Abhinav
(ACSCE, AWS SAA-C02, GAIQ)