2

We're trying to implement Anchor Link on our existing Link Component by Enabling Anchor Feature in cd_link_conf.xml

This is our configuration looks like

<Publications OverrideDiscoveryService="true">
    <Publication Id="33">
        <Host Domain="mysite.test" Port="80" Path="" Protocol="https" />
        <Linking ComponentAnchors="true" AddComponentLinkInfo="true" />
    </Publication>
</Publications>

Link schema enter image description here

and our link model class

@Data
@EqualsAndHashCode(callSuper = true)
public class Link extends AbstractEntityModel {

    @JsonProperty("linkTekst")
    private String linkTekst;

    // url property; neem externeLink als interneLink niet bestaat.
    @SemanticProperties({
            @SemanticProperty("interneLink"),
            @SemanticProperty("externeLink")
    })
    @JsonProperty("url")
    private String url;

    @SemanticProperty("interneLink")
    private EntityModel embeddedLink;

    @JsonProperty("alternatieveTekst")
    private String alternatieveTekst;
    @JsonProperty("linkStyle")
    private Tag linkStyle;
}

We came with 2 problems:

  • Anchor hash is not added in the url
  • url always use domain defined by cd_link_conf.xml. It's not dynamic following where the web application runs (e.g. on localhost, urls points to mysite.test domain instead of localhost)

Is there anything that I miss?

Specs:

  • Java application uses dxa 2.0.3 framework.
  • Dxa Model service 2.2.2
3

In general, CD Linking generates absolute URLs if you define Publication mappings in cd_link_conf.xml.

If you prefer server-relative URLs (which is often the case), you should not define any Publication elements in cd_link_conf.xml (Maybe it also works if you do define Publication elements, but no Host elements; never tried that).

Regarding ComponentAnchors=true: I’m not sure if you can make that work with DXA (again, never tried that).

Note that link resolving is typically done in the DXA Model Service, so you will have to use the DXA Model Service’s cd_link_conf.xml.

| improve this answer | |
  • The cd_link_conf.xml that I mentioned was indeed from DXA Model Service. I assume this would be officialy supported by the product? – Chris Sep 3 at 8:05
  • Changing the cd_link_config.xml of the DXA Model Service, you mean? Yes, that is supported. But not all features of CD Linking have been tested icw DXA. – Rick Pannekoek Sep 3 at 16:17

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.