Hi,
We have a page type with two properties: Heading and NavigationHeading, where NavigationHeading defaults to the value of Heading if NavigationHeading is empty (as seen below).
[ContentType(DisplayName = "MyPageType", GUID = "4c19e432-905d-46d7-bd16-ea8754a4e268", Description = "")]
public class MyPageType : PageData
{
[CultureSpecific]
[Display(
Name = "Heading",
Description = "",
GroupName = SystemTabNames.Content,
Order = 1)]
public virtual string Heading { get; set; }
[CultureSpecific]
[Display(
Name = "NavigationHeading",
Description = "",
GroupName = SystemTabNames.Content,
Order = 2)]
public virtual string NavigationHeading
{
get
{
var navigationHeading = this.GetPropertyValue(page => page.NavigationHeading);
return string.IsNullOrWhiteSpace(navigationHeading) ? Heading : navigationHeading;
}
set
{
this.SetPropertyValue(page => page.NavigationHeading, value);
}
}
}
When retrieving this page through the Content Delivery API, both properties are exposed. However, the logic expressed for NavigationHeading is not run when the page is serialized.
The table below illustrates the behaviour of the Content Delivery API for the page type above.
value of Heading in database | value of NavigationHeading in database | value of Heading in API-response | value of NavigationHeading in API-response |
<empty> | <empty> | <empty> | <empty> |
Heading | <empty> | Heading | <empty> |
<empty> | NavigationHeading | <empty> | NavigationHeading |
Heading | NavigationHeading | Heading | NavigationHeading |
However, we expect the behaviour to be like this (notice the difference in the second row)
value of Heading in database | value of NavigationHeading in database | value of Heading in API-response | value of NavigationHeading in API-response |
<empty> | <empty> | <empty> | <empty> |
Heading | <empty> | Heading | Heading |
<empty> | NavigationHeading | <empty> | NavigationHeading |
Heading | NavigationHeading | Heading | NavigationHeading |
Why isn't logic expressed in a page type's property "get"-body run when serializing objects through the Content Delivery API? What can we do to achieve this?
- Thomas