1

I'm using DXA 2.0 (JAVA) with our web app. In SDL Web 8.5, I've got a Component with a rich text field. I add a hyperlink as a Component, using a standard External Link Component, created using a schema called "External Link". and this renders:

<a title="ExternalLink" href="tcm:309-314853">sample text</a>

I publish the Page and verified ,broker database has the published Page content including the markup shown above.

The model:

@Data
@SemanticEntity(
        entityName = "EmbeddedParagraphRTF",
        vocabulary = SDL_CORE,
        prefix = "m")
public class EmbeddedParaTextEntityModel extends AbstractEntityModel {

    @SemanticProperty("m:paraText")
    @ProcessComponentLinkURL
    private String paraText;

}

Is there a way to extract the link field from the external link component in the RTF and render as a URL instead of just the tcm id which makes no sense as this is an external link.

Update: The dxa properties are as below-

## Defaults settings

# Remove XMLNS attributes from Rich Text?
dxa.defaults.rich-text-xmlns-remove=true

# Resolve TCM URIs into links in Rich Text?
dxa.defaults.rich-text-resolve=false

# Remove extension .html from resolved link?
dxa.web.link-resolver.remove-extension=true

# Strip /index at the end of resolved links?
dxa.web.link-resolver.strip-index-path=true

# keep / when stripping index at the end of resolved links?
dxa.web.link-resolver.keep-trailing-slash=false

## Error handling configuration

# Whether so suppress errors related to keyword expansion in a model
dxa.errors.missing-keyword-suppress=true

# Whether so suppress errors related to entity expansion in a model
dxa.errors.missing-entity-suppress=true

# Whether so suppress errors related to include page expansion in a page model
dxa.errors.missing-include-page-suppress=true

## Caching
# Default cache configuration if cd_client_conf.xml configuration is not compatible
dxa.caching.configuration=ehcache.xml

# List of required caches that will be created automatically if they are missing in config, comma-separated
dxa.caching.required.caches=defaultCache, failures

# List of disabled caches that will be destroyed, comma-separated
dxa.caching.disabled.caches=no-caches-are-disabled-by-default


## Tridion configuration

# Taxonomies
dxa.tridion.navigation.taxonomy.marker=[Navigation]
dxa.tridion.navigation.taxonomy.type.structureGroup=StructureGroup
dxa.tridion.navigation.taxonomy.type.taxonomyNode=TaxonomyNode
dxa.tridion.navigation.taxonomy.type.page=Page

dxa.defaults.config-bootstrap-path=/system/config/_all.json
dxa.defaults.mappings-schemas=/system/mappings/schemas.json
dxa.defaults.config-dcp-uri-field=dataPresentationTemplateUri
  • Component Link Resolving should be done by the DXA Model Service (also for Component Links in a Rich Text Field). How does the dxa.properties file of your DXA Model Service look? Is the linked Component present on a published Page? – Rick Pannekoek May 22 at 16:34
  • Rick Pannekoek The component is NOT on any published page. and I have updated the dxa properties file in the question above. – guest_2019 May 22 at 17:46
  • Ok, if the linked Component is not on a published Page, what do you expect it would resolve to? In that case, the hyperlink should get suppressed, which is apparently not happening, though. – Rick Pannekoek May 22 at 17:52
  • The dxa.properties file you included is for the Web App, but I’m interested in the one for the DXA Model Service. – Rick Pannekoek May 22 at 17:53
  • we are getting the the tcm id, and would instead need the external link that is available in the component, so that the href shows the external link and NOT the TCM – guest_2019 May 22 at 17:54
1

The Component Link doesn’t get resolved (to a Page URL) because of setting dxa.defaults.rich-text-resolve=false.

If that setting is changed to true, the DXA Model Service will resolve Component Links to Page URL, assuming the linked Component is on a published Page. If not, hyperlinks in Rich Text are suppressed (i.e. the HTML a tag is removed).

However, in your case, you don’t want such standard link resolving to happen; you want to resolve the URL in your “External Link” Component.

I would recommend to create a custom CM-side Data Model Builder for that purpose. See https://docs.sdl.com/LiveContent/content/en-US/SDL%20DXA-v10/GUID-1C3C1401-D38A-4C23-8B6D-7735C068F9B0

1

You should use type com.sdl.webapp.common.api.model.RichText (instead of String) for the RTF fields.

This should resolve links correctly.

  • Although use of type RichText makes sense in general and is really recommended if you expect embedded images (or other Media Items) in your Rich Text, I expect link resolving to work fine if you map to type String too; link resolving should be done by the DXA Model Service. – Rick Pannekoek May 22 at 16:30
  • Good explanation - thanks! – Shahid Eqamuddin May 24 at 10:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.