Try our conversational search powered by Generative AI!

Fallback properties when using ContentApi

Nat
Nat
Vote:
 

I want a number of properties to have fallbacks to other properties- such that when they are unset, a different value is returned

pretty sure I used to be able to achieve this like so

public virtual string TeaserText
  {
    get
    {
      var teaserText = this.GetPropertyValue(x => x.TeaserText);
      return string.IsNullOrWhiteSpace(teaserText) ? this.SeoDescription : teaserText;
    }

    set
    {
      this.SetPropertyValue(x => x.TeaserTitle, value);
    }
  }

however when I am calling a page with no explicit TeaserTitle set from the api, it seems to not even run the property code at all, and instead omits the property completely from the response.

feel like I am missing something.. is there anyway to deal with fallback properties reliably for V12 content api

#298412
Mar 16, 2023 7:24
Vote:
 

The Content Delivery API doesn't resolve the content models, default values should always be written to the database and not being resolved runtime. 

#298429
Mar 16, 2023 14:46
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.