Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jesper Skjønnemand 66 posts 441 karma points c-trib
    May 09, 2019 @ 13:33
    Jesper Skjønnemand
    0

    altFieldAlias in v8

    Umbraco v8 returns this when I use "insert value"

    @Model.Value("seoTitle")
    

    This works just fine, but I would like to use another value ("pageTitle") as a fallback.

    This works on a v7 site i made recently:

    @Umbraco.Field("seoTitle", altFieldAlias:"pageTitle")
    

    How would I do the same in v8? I can't seem to find any documentation on this, only about fallback to ancestor or language, which is not what I need here.

  • Marc Goodson 2157 posts 14434 karma points MVP 9x c-trib
    May 14, 2019 @ 21:56
    Marc Goodson
    102

    Hi Jesper

    It's possible but the syntax is different!

    try:

    Model.Value<string>("seoTitle", fallback: Fallback.ToDefaultValue, defaultValue: Model.Value<string>("pageTitle"))
    

    Essentially now Model.Value has three 'fallback' options if the alias of the property you are writing out is empty.

    It can fallback to default value - and the default value can be read from another property as above

    or you can Fallback.ToAncestors and read the same aliased property on a parent node going up through the content tree until a matching value is found

    or Fallback.ToLanguage if you are using variants, and a missing Swedish value should 'fallback' to English etc

    regards

    marc

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies