4

Having a Schema with for example the following structure:

  • Title: string
  • SomeComponent: ComponentLink

Where SomeComponent Schema having:

  • Text: string

When it is rendered the field "Text" from the Component Link is not being able to be edited in XPM.

Is this something that is supported in DXA for .NET 1.7 and SDL Web 8?

  • Can you perhaps edit your question and provide some more details around the View you are using in this case, since it is the Entity View that enables XPM editing in essence. – Bart Koopman Oct 20 '17 at 13:47
3

It seems to indeed be possible to edit fields in a linked Component using XPM, but it requires the XpmMetadata to be set on the Component before rendering it. For example:

myComponentPresentation.MyLinkedComponent.XpmMetadata = new Dictionary<string, object>
{
    { "ComponentID", "tcm:29-4268" },
    { "ComponentModified", "2017-10-24T08:57:35" },
    { "ComponentTemplateID", myComponentPresentation.XpmMetadata["ComponentTemplateID"] },
    { "ComponentTemplateModified", myComponentPresentation.XpmMetadata["ComponentTemplateModified"] },
    { "IsRepositoryPublished", false }
};

Now, this works if the correct ComponentID for MyLinkedComponent is supplied. For the ComponentTemplateID, it seems to be alright to pass the parent's.

The XpmMetadata is not set for linked Components in the DefaultModelBuilder. Why this is, I do not know. But it seems like it goes back to the response from the Model Service.

  • This is exactly the slight hack I was talking about in my answer, so that will also explain why the XpmMetadata is not set by default for linked Components (since it would be a hack). That being said, as I mentioned, this would indeed do the trick I think, it is a slight hack, but you might find it is working and useful. – Bart Koopman Jan 26 '18 at 9:42
7

Funny enough I just answered a question in email about the same and came to an interesting conclusion.

To inline edit a field in XPM, it needs to belong to a Component Presentation and the proper XPM markup for the Component Presentation and the field need to be present on the page.

Now a Linked Component, is not a Component Presentation, you only have a Component URI, and not a Component Template URI for it. So if you would debug your web application, you would find that the Entity Model for your Linked Component will not have complete or valid XpmMetadata available. So it isn't possible to generate the XPM markup for this. So that brings us to the conclusion that indeed you are not able to edit fields of a linked Component in DXA 1.7 (please note you should be able to edit the Component Link field itself, i.e. change the link to a different Component).

I have been thinking about how we could possibly support this in the future, and that can be one of the following options:

  1. a change in XPM where it is possible to edit just a Component and not only Component Presentations
  2. a slight hack in DXA for editing linked Components, by using a dummy Component Template URI (this would be a real Component Template URI, which is only used for editing linked Components).
  • Thanks for your answer. I think the person that you got the email was looking at the issue with me :) – Diego Oct 27 '17 at 14:51

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.