1

Given this modelling part, relevant for the linking.

enter image description here

Component linking should be implement for linking to:

1. Inside website

Linking to e.g. article, article-top-tasks.
Created field with XML name "internalLink" for schema and model.
It works without Link (schema/model). Why? I was suprised ;-)

2.Outsite website

Created schema "ExterneLink" (for reuse), it contains 1 field for Url.
To get this to work, schema and model defined, can us it value in class/view.
Advantage: Works. It's also normal for embedded of component linking.
Disadvantage: Extra field.

Example for 1: Inside website 'Tegel' (Tile)

enter image description here

Example for 2 extended for Outside website

enter image description here

Questions:

Q1- Can you custom (extend/change) Link schema e.g. icon or drop altText?

Core example application use "Link" schema.
Sdl.Web.Common.Model.Link has model in Dxa Framework.
I made a Link model myself, when tested the Url is NOT resolved. Why?

Q2- Created schema/model "List item" instead of "Link".

Advantage and disadvantage?

Q3- Multimedia schema "Document" for upload/link "Pdf files".

Will it work with xml name "internalLink" (like inside website above)?

4
  • See PlantUML for modelling (like this drawing). Commented Dec 31, 2020 at 0:08
  • Supporting both internal and external links is quite common and can be implemented using a single View Model property. See docs.sdl.com/784837/557501/… Commented Jan 1, 2021 at 11:08
  • Please clarify your requirements for using an embedded Schema/Model for the external link (and for changing the Link model). Commented Jan 1, 2021 at 11:09
  • Content Manager fields (1x CL [insite],1x url [outsite] and mapping to one field in model as string work. Discovered not restrited to xmlnames (internalLink,externalLink). Can define Link but also as model Link? Requirements: 1. customable icon in view, can do it in Link schema? No AlternateText. 2. url [outsite] must be occurs once, and used in datamodel on different places (called ExterneLink). Commented Jan 1, 2021 at 15:27

1 Answer 1

3

Frankly, I don’t fully understand all of your questions nor requirements, but let me clarify some things:

  • Semantic mapping does not presume any field names; field names are either derived from the View Model property names or explicitly specified in [SemanticProperty] annotations. So, your statement “other XML names than internalLink doesn’t work” is incorrect.
  • The semantic mapping automatically resolves Component Links if you map a Component Link field to a property of type String or Link (in the latter case it also preserves the Component ID in Link.Id)
  • A Component Link field can also be mapped to an embedded Entity Model (i.e. a property of type EntityModel or a subclass).
    • In this case, full semantic mapping is applied to the embedded Entity Model.
    • If this embedded Entity Model has a property of type String or Link annotated with [SemanticProperty(“_self”)], you can also get the resolved link URL.
    • If the embedded Entity Model derives from MediaItem (which, in turn, derives from EntityModel) and the linked Component is a Multimedia Component, the Media Item’s URL (and other properties) will also be set.
    • The semantic mapping resolves the embedded Entity Model type from the linked Component’s Schema (through semantic type mappings and type registration). This is sometimes referred to as polymorphic mapping.

To fully understand how semantic mapping works, have a look at the DefaultModelBuilder implementation, in particular: the MapXYZ methods.

1
  • Thanks. It's clear up, flexible that type String or Link can be used. Removed Q4. Commented Jan 1, 2021 at 19:50

Your Answer

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

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