Quantcast
Channel: Developer to developer
Viewing all articles
Browse latest Browse all 9076

Episerver 11 - DisplayTemplates for LinkItemCollection

$
0
0

Alloy, Episerver 11.10.1.

On StartPage, I've created a new property:

[UIHint("MyUiHint")]
[Display(
    GroupName = SystemTabNames.Settings,
    Order = 100)]
public virtual LinkItemCollection MyProperty{ get; set; }

Under Views/Shared/DisplayTemplates, I've created a new view - MyUiHint.cshtml

If I use @Html.PropertyFor(x => x.CurrentPage.MyProperty) inside Views/StartPage/Index.cshtml, everything works as expected. Episerver will use MyUiHint.cshtml to render the property.

However, if I want to make MyProperty available inside LayoutModel and use @Html.PropertyFor(x => x.Layout.MyProperty), Episerver will use the default template instead of MyUiHint.cshtml. If I then click on the property in On-Page editing mode and close the popup, Episerver will switch to MyUiHint.cshtml. However, as soon as I switch the view (for example, go to All Properties view and then back to On-Page editing view), Episerver will again use the default template instead of MyUiHint.cshtml.

Is this a known issue?


Viewing all articles
Browse latest Browse all 9076

Trending Articles