Pagefield is not adding .html extension to internal URLs in QA instances | Community
Skip to main content
Level 3
November 9, 2023
Solved

Pagefield is not adding .html extension to internal URLs in QA instances

  • November 9, 2023
  • 3 replies
  • 1957 views

Hi Team,

 

I'm using cq/gui/components/coral/common/form/pagefield for any link refs to be authored. It is adding .html to internal URLs and not adding the .html to external URLs. All this is working fine in my local instance but when this change is deployed to QA, it does not add the extension of .html to internal URLs as well.

 

Tried using this as well granite/ui/components/coral/foundation/form/pathfield but this doesn't add extension at all even in local instance.

 

Are there any configuration changes that need to be enabled/disabled on the QA instance? Or is there any other resource type that we should be using for Link fields that differentiate the internal and external URLs?

 

Any help is appreciated.

 

Thanks,

Manasa

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 arunpatidar

Hi @arunpatidar 

Yeah, that is the same node structure in my local instance too. It adds .html perfectly fine in Local but not on actual QA, and Stage instances. Regarding the config that you were talking about, can you let me know which exact attribute in the config should I be validating between Local and QA to understand the difference in behavior?


You should check org.apache.sling.jcr.resource.internal.JcrResourceResolverFactoryImpl  or /etc/map or link rewrite can be found at /apps/yourprojrct/config

 

It maybe possible that In your local, the link transformer maybe activated by another project.

 

Try with vanilla instance and your project code.

3 replies

arunpatidar
Community Advisor
Community Advisor
November 10, 2023

Hi @manasabojja7 
PathField does not add extension automatically, 

you might have rewrite configuration that adds html after the path.

Please org.apache.sling.jcr.resource.internal.JcrResourceResolverFactoryImpl config, where it is working. You might be missing configs

 

https://abhigyanswaroop.medium.com/resource-mapping-in-adobe-experience-manager-aem-1658653a683 

Arun Patidar
Level 3
November 10, 2023

Thanks @arunpatidar for the response.

 

Using cq/gui/components/coral/common/form/pagefield resourceType is adding .html automatically. Do you mean that the config might be on the local instance for PageField?

arunpatidar
Community Advisor
Community Advisor
November 13, 2023

Hi @manasabojja7 
Yes, you should check the config.

Can you also share the crxde content node where values are stored from pagefield?

Arun Patidar
ShaileshBassi
Community Advisor
Community Advisor
November 14, 2023

Hi @manasabojja7 

This can also be achieved by adding the below logic in your component

<sly data-sly-test.linkCheck="${links.linkPath}"></sly>

<div data-sly-test.internalLink="${'/content/' in linkCheck}"><a href="${links.linkPath}.html"
target="${links.linksTarget}"><span> ${links.linkTitle} </span></a></div>

 

Otherwise read the value of the field within the SlingModel and return the final value adding .html in the url from the backend logic itself.

 

Hope this helps!

Thanks

Level 3
November 14, 2023

Thanks for your response @shaileshbassi 

 

I'm mostly looking to see if it can be done without this additional logic.

 

Using the cq/gui/components/coral/common/form/pagefield resourceType seems to work fine for both internal (adding .html) and external (not adding the extension) on my local instance but fails to behave the same in the QA instance.

kautuk_sahni
Community Manager
Community Manager
November 14, 2023

@manasabojja7 Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.

Kautuk Sahni