Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
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.
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
is working on a reply...
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.
Continue discussion
altFieldAlias in v8
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:
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.
Hi Jesper
It's possible but the syntax is different!
try:
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
is working on a reply...
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.