Configring Internal or External Link in Pathbrowser in AEM 6.2 | Community
Skip to main content
ashish_kumarm48
Level 2
February 14, 2017
Solved

Configring Internal or External Link in Pathbrowser in AEM 6.2

  • February 14, 2017
  • 6 replies
  • 5973 views

I have a component of resource type - granite/ui/components/foundation/form/pathbrowser , i need to make sure in case of internal link .html to be appended whereas in case of external link it should be as it is no .html appending. Can anyone help?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by ashish_kumarm48

In case of Touch UI, we need to make use of Java Code only, I was not able to find any other options.

This is the code which I tried and it worked for me.

Here I am checking for the 4 cases:

1. Checking for file extension:- so if the file extension is .mp4 or .mp3 like that then we are not processing the URL and simply returning it.to check the different extension we have created an enum class. like this.

case 2: if URL is null or empty then we are sending null.

case 3: if URL starts with "/content" then we are appending ".html"

case 4: if URL starts with "http" or "https" or "www" then we are simply sending back the URL without performing any operation as it is an external link.

6 replies

Jitendra_S_Toma
Level 10
February 14, 2017

Once you get user input and before displaying it as a link, check if this is internal page or not. You can PageManger & Resource API for this. 

ashish kumarm48760261 wrote...

I have a component of resource type - granite/ui/components/foundation/form/pathbrowser , i need to make sure in case of internal link .html to be appended whereas in case of external link it should be as it is no .html appending. Can anyone help?

 

Level 3
February 14, 2017

Jitendra S.Tomar wrote...

Once you get user input and before displaying it as a link, check if this is internal page or not. You can PageManger & Resource API for this. 

ashish kumarm48760261 wrote...

I have a component of resource type - granite/ui/components/foundation/form/pathbrowser , i need to make sure in case of internal link .html to be appended whereas in case of external link it should be as it is no .html appending. Can anyone help?

 

 

 

The whole point is to avoid doing backend code checks. The "linkpattern" config options for pathfield would enable us to handle it all by itself.  Check the API here is the API snippet.

linkPattern : String

A pattern to format links after selection in the browse dialog (using CQ.Util.patchText). This is used when only a tree item is selected (which is always the case if parBrowse = false). It has only one argument '{0}', which is the path from the tree. See also parLinkPattern.
 

Defaults to '{0}.html' if parBrowse = true, otherwise simply '{0}'.

Writing an explict condition in the backend code to add .html is not required.

ashish_kumarm48
Level 2
February 15, 2017

Yeah but here i am working in Touch UI (granite/ui/components/foundation/form/pathbrowser ) for AEM 6.2 , so this property seems to be invalid for this case.

rampai
Community Advisor
Community Advisor
December 9, 2017

Do we have an answer for this? How to configure this in touch UI pathbrowser?

May 28, 2018

Hi,

Did you get an answer to it how it could be accomplished in touchui?

ashish_kumarm48
ashish_kumarm48AuthorAccepted solution
Level 2
May 28, 2018

In case of Touch UI, we need to make use of Java Code only, I was not able to find any other options.

This is the code which I tried and it worked for me.

Here I am checking for the 4 cases:

1. Checking for file extension:- so if the file extension is .mp4 or .mp3 like that then we are not processing the URL and simply returning it.to check the different extension we have created an enum class. like this.

case 2: if URL is null or empty then we are sending null.

case 3: if URL starts with "/content" then we are appending ".html"

case 4: if URL starts with "http" or "https" or "www" then we are simply sending back the URL without performing any operation as it is an external link.