Expand my Community achievements bar.

SOLVED

AEM 6.5 open help in new tab

Avatar

Level 7

Hi Team,
I have to add a new field in the help section and open that filed in new window  which is like

tushaar_srivastava_0-1739956875263.png

For that, I can simply overlay the

 /libs/granite/ui/content/shell/help/items/home to /apps/granite/ui/content/shell/help/items/home and provide the custom fields

tushaar_srivastava_1-1739957038085.png


But the problem is all the icons under help open in same window, but I want the custom button to open in a new window,
How can I do that?

 

Thanks

 

@kautuk_sahni  @arunpatidar  @lukasz-m  @VeenaVikraman 

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Level 7

Hi @tushaar_srivastava ,

You need to add the target arrtibute in this file - /libs/granite/ui/components/shell/help/item/item.jsp

attrs.add("target","_blank");

if you want this to be dynamic and configurable for each help options, then add a property called target in each help items like below and read the same in the above JSP attrs.add("target",cfg.get("target", String.class)); instead of hardcoding

narendiran_ravi_0-1739975140998.png

 

After adding this, you need to allow this attribute in the allowed list -/libs/granite/ui/components/coral/foundation/clientlibs/foundation/js/xss/xss.js as all HTML response is sanitized for XSS protection.

ADD_ATTR: [
                "coral-close", "tracking", "trackingelement", "trackingfeature", "variant", "is",
                "form", "fieldtrackingidentifier", "trackingWidget", "coral-wizardview-next",
                "coral-wizardview-previous", "iconposition", "iconsize", "icon", "iconautoarialabel", "block",
                "sticky", "labelledby","target"
            ]

You need to overlay all these libs path under your apps before adding these custom changes

View solution in original post

3 Replies

Avatar

Correct answer by
Level 7

Hi @tushaar_srivastava ,

You need to add the target arrtibute in this file - /libs/granite/ui/components/shell/help/item/item.jsp

attrs.add("target","_blank");

if you want this to be dynamic and configurable for each help options, then add a property called target in each help items like below and read the same in the above JSP attrs.add("target",cfg.get("target", String.class)); instead of hardcoding

narendiran_ravi_0-1739975140998.png

 

After adding this, you need to allow this attribute in the allowed list -/libs/granite/ui/components/coral/foundation/clientlibs/foundation/js/xss/xss.js as all HTML response is sanitized for XSS protection.

ADD_ATTR: [
                "coral-close", "tracking", "trackingelement", "trackingfeature", "variant", "is",
                "form", "fieldtrackingidentifier", "trackingWidget", "coral-wizardview-next",
                "coral-wizardview-previous", "iconposition", "iconsize", "icon", "iconautoarialabel", "block",
                "sticky", "labelledby","target"
            ]

You need to overlay all these libs path under your apps before adding these custom changes

Avatar

Community Advisor

Avatar

Level 9

Hi @tushaar_srivastava@narendiran_ravi 

 

Actually, there is more easy and extendable solution without touching/overlaying JSP.

 

Step 1: Overlay node with help items 
Example:

Node: /apps/granite/ui/content/shell/help/items/test

Properties:

Node: /apps/granite/ui/content/shell/help/items/test/granite:data

Properties:

  • target: _blank

 

Step 2: Create clientlib with extension

categories: granite.ui.shell

extension.js

(function(document, $) {
    "use strict";
    $(document).on('foundation-toggleable-show', function(event) {
    	$(event.target).find('.granite-shell-help ._coral-Shell-help-item').each(function(index, helpItem) {
        	const $helpItem = $(helpItem);
        	if ($helpItem.data('target')) {
            	$helpItem.attr('target', $helpItem.data('target'));
        	}
    	});  
    }) 
})(document, Granite.$);

 

konstantyn_diachenko_0-1740079632410.png

 

Best regards,

Kostiantyn Diachenko.