@using Umbraco.Cms.Core.PublishedCache;
@inject IPublishedSnapshotAccessor _publishedSnapshotAccessor;
@{
// Set the value of the property with alias 'footerLinks'
content.SetValue(Home.GetModelPropertyType(_publishedSnapshotAccessor, x => x.FooterLinks).Alias, links);
}
with no context of how to use it.
Is this example is Home referring to the Page Type?
is FooterLinks the name of the property in the Home Page?
That example is showing how to programmatically set a value in Umbraco for a MultiUrlPicker.
Imagine if you were writing an import routine, to bring content from a legacy system, and make it editable via Umbraco.
The legacy content might have a title an image some text and a link.
You'd define a document type of a text, media picker, rte and a multi url picker.
You use the ContentService, which is the gateway for CRUD actions with Umbraco content (warning: don't use it for rendering content, always use the published cache for that) to achieve this import.
Each property is set by its alias.
Each type of property needs the content to be provided in different formats depending on how the data is stored.
The documentation is showing you how to set a MultiUrlPicker content programmatically with the ContentService
The first example shows using the alias as a string "footerLinks" but some people don't like this approach, if the alias changed, or was mistyped, you Only find out at runtime, so the second example, is showing how, with modelsbuilder, youcan get ygat alias from the generated model, so if it ever changed, the project wouldn't build, and you'd find the potential problem before deploying!
Links (explain documentation)
I am using a Multi Url Picker (with a limit of 1 URL) with Modelsbuilder enabled
and I am referencing the documentation here:
https://docs.umbraco.com/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/multi-url-picker
but the only code that is showing is
with no context of how to use it.
Is this example is Home referring to the Page Type? is FooterLinks the name of the property in the Home Page?
Any feedback would be greatly appreciated
Hi Yaco
That example is showing how to programmatically set a value in Umbraco for a MultiUrlPicker.
Imagine if you were writing an import routine, to bring content from a legacy system, and make it editable via Umbraco.
The legacy content might have a title an image some text and a link.
You'd define a document type of a text, media picker, rte and a multi url picker.
You use the ContentService, which is the gateway for CRUD actions with Umbraco content (warning: don't use it for rendering content, always use the published cache for that) to achieve this import.
Each property is set by its alias.
Each type of property needs the content to be provided in different formats depending on how the data is stored.
The documentation is showing you how to set a MultiUrlPicker content programmatically with the ContentService
The first example shows using the alias as a string "footerLinks" but some people don't like this approach, if the alias changed, or was mistyped, you Only find out at runtime, so the second example, is showing how, with modelsbuilder, youcan get ygat alias from the generated model, so if it ever changed, the project wouldn't build, and you'd find the potential problem before deploying!
Regards
Marc
is working on a reply...