0

I am trying to get a component to link to an external location to work in rich text.

I found some articles with similar issues but none of them seem to have a working solution for our case.

We are using Tridion Sites 9 and DXA 2.2. When adding the component as a referece in rich text, it looks like this: <p>This is a <a href="tcm:98-418208" title="Title">link</a> from the external link component</p>

When publishing, this will not resolve, which is understandable as the components isn't on one of our pages somewhere, it is meant to link to some external page.

We have thought about just putting the external link itself into the href, but this is undesirable because the idea of these external link components is that when a link changes there's only 1 place we have to change the link at, rather than everywhere we point to that link.

We have also thought of publishing this external link component on a page and then redirecting calls to that page to our external link.

This would mean changing the actual link in 2 places should it change, as well as the need for a hidden page for every single external link we wish to use in rich text.

The third option we have researched is adapting the data model, but we haven't figured out how we should change it to get this reference resolved without having to publish the link component to a page and if that is even possible at all.

So, summarizing: We want to link to an external location in rich text without putting the link directly into the rich text but are not sure what the best option to do so is.

3
  • welcome to Tridion StackExchange , Please refer to this link --> tridion.stackexchange.com/questions/21449/… , see if this helps
    – Anand N S
    Apr 22, 2021 at 7:52
  • @AnandNS That was our starting point. The issue we're running into is the answer Rick Pannekoek gives in that ticket. Waht we're now wondering is how to work around that. The component won't link because it didn't provide results as it is looking for the component itself rather than what is in the component. If we were to publish the external link component somewhere, this type of linking would still only bring us to where we publish it rather than to the external link that is in it.
    – Christel
    Apr 22, 2021 at 9:39
  • Note that it's not just DXA that won't resolve links to Components that aren't published. The core Content Delivery has the same logic to resolve Dynamic Component Links to either where the Component is published or to remove the link if the item can't be found in CD. By default, neither the Content Manager nor Content Delivery would actually know you wanted to replace a Component link with the contents of that link. :-) Feb 11, 2022 at 7:21

1 Answer 1

0

Having Components store external links is definitely a familiar practice, especially if there's a large library of external link options and it's possible for them to change.

The main options I'd recommend are either Content Manager-side rendering (templating) of the links or an External Content Library provider.

Templating

The idea of templating the links is to replace the TCM URI in your link with either the actual hyperlinks or some format that DXA can then work with.

Templating those external links would involve a Template Building Block (TBB) to detect links to that specific type of Component (based on the linked Schema, for example), and to retrieve the external link. Preferably, those linked Components have just an external field.

Though you might be able to name a fairly empty Component with the URL itself.

URL in the title

Be sure this TBB runs before other link resolving logic.

External Content Library

The External Content Library allows editors to link to and select from items that are external to the CMS. Typical use cases are integrations with a Digital Asset Management (DAM) system or 3rd-party image hosting site. However, it can also be used to link to any kind of data available over an API.

I've even seen an implementation use an ECL provider for a CMS to connect to classification stored within the same CMS.

The approach with ECL would be to store and manage your list of URLs in some file or system. Then the ECL provider logic would be to read and expose those external URLs to the CMS.

Editors could then browse and select an "external" link from Component link fields as well as rich text format areas. The rest of the ECL logic would then be to convert the ECL links to the desired URLs, which could occur in the CM or CD.

Based on the effort and relatively simple use case, I'd recommend a TBB over ECL.

TCDL

You might also consider extending TCDL with a custom tag, though I'm not sure that's still possible or preferred in the latest version of Tridion Sites. Refer to the Document Center to learn more about custom TCDL tags.

Finally, if the external URLs are infrequently used or rarely need updating, consider having editors directly insert external hyperlinks links in rich text format areas. This is how most other systems handle links. Though a change to an external URL might mean multiple updates in the CMS, it's worth comparing that effort to always needing to make or double-check for an existing external link.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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