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

    Umbraco v8 returns this when I use "insert value"


    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 2148 posts 14353 karma points MVP 8x c-trib
    May 14, 2019 @ 21:56
    Marc Goodson

    Hi Jesper

    It's possible but the syntax is different!


    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



Please Sign in or register to post replies

Write your reply to: