TransWikia.com

DxaPropertyMarkup for managing lists of items in XPM

Tridion Asked by Chris Mills on March 5, 2021

I have a list of Embedded Schema objects that I want to be able to reorder, add, and remove in the list in XPM.

I cannot find any examples of the correct DxaPropertyMarkup to be able to do this.

@if (item.calltoaction.Count > 0)
{
    <ul class="unstyled">
        @foreach (EmbeddedCallToAction calltoaction in item.calltoaction)
        {

            <li @Html.DxaPropertyMarkup(() => item.calltoaction)>
                <a class="@htmlClasses" href="@link" target="@target" title="@title" @Html.DxaPropertyMarkup(() => calltoaction.externallink)>
                    <span @Html.DxaPropertyMarkup(() => calltoaction.label)>@label</span>

                </a>
            </li>
        }
    </ul>
}

One Answer

To get the add, remove, reorder functionality for multivalue properties, you must use the DxaPropertyMarkup method with an index. For multivalue "embedded properties", this should wrap all individual property markups.

@Html.DxaPropertyMarkup(() => Model.MultiValueProperty, index)

In your example, the following line needs to be modified:

<li @Html.DxaPropertyMarkup(() => item.calltoaction)>

As a reference, there is an example in the Core module here (line 15).

Correct answer by Atila Sos on March 5, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP