Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

Absolute URL for assets and links localized to AEM in content fragments

Avatar

Level 2

Hi Experts,

 

We have a use case to send the absolute or full URL's for localized assets/links configured from AEM in fragments. This is being consumed by another non aem application by making model json API call. The content fragments authored with links have relative URL's in JSON. Is there a way to achieve this without code changes at present in AEM 6.4.x version? If not, could you please let us know how we can achieve or go about this request?

 

Edit: This query is not related to custom components created using sling models or at component level. It's Absolute url for all assets and content links to be available for all content fragments created using a content model. 

 

Thanks.

Topics

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

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

If you are using Sling Model to send the URL to JSON, you can construct the Url explicitly in the URL variable

 

@ValueMapValue
@Deleted Account
private String fullurl;

 

@PostConstruct
private void activate(){
// build the Full URL with absolute path
fullurl = <<<construct -- path>>> ;
}

View solution in original post

5 Replies

Avatar

Correct answer by
Community Advisor

If you are using Sling Model to send the URL to JSON, you can construct the Url explicitly in the URL variable

 

@ValueMapValue
@Deleted Account
private String fullurl;

 

@PostConstruct
private void activate(){
// build the Full URL with absolute path
fullurl = <<<construct -- path>>> ;
}

Avatar

Level 2

Hi @SureshDhulipudi,

This is applicable for individual or custom component implemented using sling models, which is not relevant for our case. Our use case is to have absolute url for all assets and content links to be available for all the content fragments created using content model whenever a JSON GET call is made to it.

Thanks 

Avatar

Community Advisor
can you write logic in consumer application?, construct the Full URL in consumer application after reading the JSON, apply the logic in consumer JSON read method

Avatar

Level 2
Hi @SureshDhulipudi, We don't have control on consumer end in this case. Moreover it's reasonable that consumer is expecting AEM to send Absolute URL, reason being that it can be an non AEM application and /content/dam* or /content/* does not give any context for them. Thanks

Avatar

Community Advisor
I don't think this is possible without a custom JSON or JSON Exporter, OOTB model.json will provide only relative URLs / paths of the content and assists. You have to write a custom JSON Exporter and Service to give absolute path in JSON