From 2c08295b6b99f472a296162a263fafd9f88f9418 Mon Sep 17 00:00:00 2001 From: kjac Date: Tue, 20 May 2025 09:55:00 +0200 Subject: [PATCH 1/2] Removed IPublishedSnapshotAccessor from V15 code samples --- .../checkbox-list.md | 36 +++++++-------- .../color-picker.md | 38 +++++++--------- .../content-picker.md | 29 +++++------- .../date-time.md | 27 +++++------ .../decimal.md | 27 +++++------ .../document-picker.md | 31 +++++-------- .../dropdown/README.md | 33 ++++++-------- .../eye-dropper-color-picker.md | 29 +++++------- .../file-upload.md | 45 ++++++++----------- .../label.md | 43 ++++++++---------- .../markdown-editor.md | 27 +++++------ .../media-picker-3.md | 35 +++++++-------- .../member-group-picker.md | 30 +++++-------- .../member-picker.md | 32 +++++-------- .../multi-url-picker.md | 29 +++++------- .../multiple-textbox.md | 27 +++++------ .../numeric.md | 29 +++++------- .../radiobutton-list.md | 27 +++++------ .../rich-text-editor-tinymce/README.md | 25 +++++------ .../rich-text-editor/README.md | 25 +++++------ .../slider.md | 41 +++++++---------- .../built-in-umbraco-property-editors/tags.md | 27 +++++------ .../textarea.md | 29 +++++------- .../textbox.md | 28 +++++------- .../true-false.md | 28 +++++------- .../user-picker.md | 25 +++++------ .../backoffice/settings-dashboards.md | 11 ++--- .../templating/modelsbuilder/introduction.md | 28 ++++++------ .../modelsbuilder/understand-and-extend.md | 10 ++--- 29 files changed, 350 insertions(+), 501 deletions(-) diff --git a/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/checkbox-list.md b/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/checkbox-list.md index c9b965db5c3..a548f410b35 100644 --- a/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/checkbox-list.md +++ b/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/checkbox-list.md @@ -26,7 +26,7 @@ You can use dictionary items to translate the options in a Checkbox List propert ## MVC View Example -### Without Modelsbuilder +### Without Models Builder ```csharp @{ @@ -42,7 +42,7 @@ You can use dictionary items to translate the options in a Checkbox List propert } ``` -### With Modelsbuilder +### With Models Builder ```csharp @{ @@ -67,25 +67,22 @@ The example below demonstrates how to add values programmatically using a Razor {% endhint %} ```csharp -@inject IContentService Services; @using Umbraco.Cms.Core.Serialization -@using Umbraco.Cms.Core.Services; -@inject IJsonSerializer Serializer; +@using Umbraco.Cms.Core.Services +@inject IContentService ContentService +@inject IJsonSerializer Serializer @{ - // Get access to ContentService - var contentService = Services; - // Create a variable for the GUID of the page you want to update var guid = Guid.Parse("32e60db4-1283-4caa-9645-f2153f9888ef"); // Get the page using the GUID you've defined - var content = contentService.GetById(guid); // ID of your page + var content = ContentService.GetById(guid); // ID of your page - // Set the value of the property with alias 'superHeros'. - content.SetValue("superHeros", Serializer.Serialize(new[] { "Umbraco", "CodeGarden"})); + // Set the value of the property with alias 'superHeroes'. + content.SetValue("superHeroes", Serializer.Serialize(new[] { "Umbraco", "CodeGarden"})); // Save the change - contentService.Save(content); + ContentService.Save(content); } ``` @@ -94,20 +91,17 @@ Although the use of a GUID is preferable, you can also use the numeric ID to get ```csharp @{ // Get the page using it's id - var content = contentService.GetById(1234); + var content = ContentService.GetById(1234); } ``` -If Modelsbuilder is enabled you can get the alias of the desired property without using a magic string: - -{% include "../../../../.gitbook/includes/obsolete-warning-ipublishedsnapshotaccessor.md" %} +If Models Builder is enabled you can get the alias of the desired property without using a magic string: ```csharp -@inject IPublishedSnapshotAccessor _publishedSnapshotAccessor; -@using Umbraco.Cms.Core.PublishedCache; +@using Umbraco.Cms.Core.PublishedCache +@inject IPublishedContentTypeCache PublishedContentTypeCache @{ - -// Set the value of the property with alias 'superHeros' -content.SetValue(Home.GetModelPropertyType(_publishedSnapshotAccessor,x => x.SuperHeros).Alias, Serializer.Serialize(new[] { "Umbraco", "CodeGarden"})); + // Set the value of the property with alias 'superHeroes' + content.SetValue(Home.GetModelPropertyType(PublishedContentTypeCache, x => x.SuperHeroes).Alias, Serializer.Serialize(new[] { "Umbraco", "CodeGarden"})); } ``` diff --git a/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/color-picker.md b/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/color-picker.md index f6399f438bd..b98eb924638 100644 --- a/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/color-picker.md +++ b/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/color-picker.md @@ -20,7 +20,7 @@ It is possible to add a label to use with the color. ![Color Picker Content](../../../../../../10/umbraco-cms/fundamentals/backoffice/property-editors/built-in-property-editors/images/Color-Picker-Content-v8.png) -## Example with Modelsbuilder +## Example with Models Builder ```csharp @{ @@ -36,7 +36,7 @@ It is possible to add a label to use with the color. } ``` -## Example without Modelsbuilder +## Example without Models Builder ```csharp @using Umbraco.Cms.Core.PropertyEditors.ValueConverters @@ -64,48 +64,42 @@ The example below demonstrates how to add values programmatically using a Razor ### Without labels ```csharp -@inject IContentService Services; -@using Umbraco.Cms.Core.Services; +@using Umbraco.Cms.Core.Services +@inject IContentService ContentService @{ - // Get access to ContentService - var contentService = Services; - // Create a variable for the GUID of the page you want to update var guid = Guid.Parse("32e60db4-1283-4caa-9645-f2153f9888ef"); // Get the page using the GUID you've defined - var content = contentService.GetById(guid); // ID of your page + var content = ContentService.GetById(guid); // ID of your page // Set the value of the property with alias 'color'. // The value set here, needs to be one of the colors on the Color Picker content.SetValue("color", "38761d"); // Save the change - contentService.Save(content); + ContentService.Save(content); } ``` ### With labels ```csharp -@inject IContentService Services; -@using Umbraco.Cms.Core.Services; +@using Umbraco.Cms.Core.Services +@inject IContentService ContentService @{ - // Get access to ContentService - var contentService = Services; - // Create a variable for the GUID of the page you want to update var guid = Guid.Parse("32e60db4-1283-4caa-9645-f2153f9888ef"); // Get the page using the GUID you've defined - var content = contentService.GetById(guid); // ID of your page + var content = ContentService.GetById(guid); // ID of your page // Set the value of the property with alias 'color'. // The value set here, needs to be one of the colors on the Color Picker content.SetValue("color", "{'value':'000000', 'label':'Black', 'sortOrder':1, 'id':'1'}"); // Save the change - contentService.Save(content); + ContentService.Save(content); } ``` @@ -114,19 +108,17 @@ Although the use of a GUID is preferable, you can also use the numeric ID to get ```csharp @{ // Get the page using it's id - var content = contentService.GetById(1234); + var content = ContentService.GetById(1234); } ``` -If Modelsbuilder is enabled you can get the alias of the desired property without using a magic string: - -{% include "../../../../.gitbook/includes/obsolete-warning-ipublishedsnapshotaccessor.md" %} +If Models Builder is enabled you can get the alias of the desired property without using a magic string: ```csharp -@inject IPublishedSnapshotAccessor _publishedSnapshotAccessor; -@using Umbraco.Cms.Core.PublishedCache; +@using Umbraco.Cms.Core.PublishedCache +@inject IPublishedContentTypeCache PublishedContentTypeCache @{ // Set the value of the property with alias 'color' - content.SetValue(Home.GetModelPropertyType(_publishedSnapshotAccessor, x => x.Color).Alias, "38761d"); + content.SetValue(Home.GetModelPropertyType(PublishedContentTypeCache, x => x.Color).Alias, "38761d"); } ``` diff --git a/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/content-picker.md b/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/content-picker.md index 59f53d6e103..4548605ef3e 100644 --- a/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/content-picker.md +++ b/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/content-picker.md @@ -200,7 +200,7 @@ When opening the picker on the `Umbraco anno MMXXIII` node, it will now show the ## MVC View Example -### Without Modelsbuilder +### Without Models Builder ```csharp @{ @@ -213,7 +213,7 @@ When opening the picker on the `Umbraco anno MMXXIII` node, it will now show the } ``` -### With Modelsbuilder +### With Models Builder ```csharp @{ @@ -234,19 +234,15 @@ The example below demonstrates how to add values programmatically using a Razor {% endhint %} ```csharp -@inject IContentService Services; -@using Umbraco.Cms.Core; +@using Umbraco.Cms.Core @using Umbraco.Cms.Core.Services - +@inject IContentService ContentService @{ - // Get access to ContentService - var contentService = Services; - // Create a variable for the GUID of the page you want to update var guid = Guid.Parse("32e60db4-1283-4caa-9645-f2153f9888ef"); // Get the page using the GUID you've defined - var content = contentService.GetById(guid); // ID of your page + var content = ContentService.GetById(guid); // ID of your page // Get the pages you want to assign to the Content Picker var page = Umbraco.Content("665d7368-e43e-4a83-b1d4-43853860dc45"); @@ -263,7 +259,7 @@ The example below demonstrates how to add values programmatically using a Razor content.SetValue("featuredArticles", string.Join(",", udis)); // Save the change - contentService.Save(content); + ContentService.Save(content); } ``` @@ -272,20 +268,17 @@ Although the use of a GUID is preferable, you can also use the numeric ID to get ```csharp @{ // Get the page using it's id - var content = contentService.GetById(1234); + var content = ContentService.GetById(1234); } ``` -If Modelsbuilder is enabled you can get the alias of the desired property without using a magic string: - -{% include "../../../../.gitbook/includes/obsolete-warning-ipublishedsnapshotaccessor.md" %} +If Models Builder is enabled you can get the alias of the desired property without using a magic string: ```csharp -@inject IPublishedSnapshotAccessor _publishedSnapshotAccessor; -@using Umbraco.Cms.Core.PublishedCache; - +@using Umbraco.Cms.Core.PublishedCache +@inject IPublishedContentTypeCache PublishedContentTypeCache @{ // Set the value of the property with alias 'featuredArticles' - content.SetValue(Home.GetModelPropertyType(_publishedSnapshotAccessor ,x => x.FeaturedArticles).Alias, string.Join(",", udis)); + content.SetValue(Home.GetModelPropertyType(PublishedContentTypeCache, x => x.FeaturedArticles).Alias, string.Join(",", udis)); } ``` diff --git a/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/date-time.md b/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/date-time.md index d566af2ee51..41a6b0bb150 100644 --- a/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/date-time.md +++ b/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/date-time.md @@ -22,13 +22,13 @@ The setting involves defining the format. The default date format in the Umbraco ## MVC View Example - displays a datetime -### With Modelsbuilder +### With Models Builder ```csharp @Model.DatePicker ``` -### Without Modelsbuilder +### Without Models Builder ```csharp @Model.Value("datePicker") @@ -43,23 +43,20 @@ The example below demonstrates how to add values programmatically using a Razor {% endhint %} ```csharp -@inject IContentService Services; -@using Umbraco.Cms.Core.Services; +@using Umbraco.Cms.Core.Services +@inject IContentService ContentService @{ - // Get access to ContentService - var contentService = Services; - // Create a variable for the GUID of the page you want to update var guid = new Guid("32e60db4-1283-4caa-9645-f2153f9888ef"); // Get the page using the GUID you've defined - var content = contentService.GetById(guid); // ID of your page + var content = ContentService.GetById(guid); // ID of your page // Set the value of the property with alias 'datePicker' content.SetValue("datePicker", DateTime.Now); // Save the change - contentService.Save(content); + ContentService.Save(content); } ``` @@ -68,20 +65,18 @@ Although the use of a GUID is preferable, you can also use the numeric ID to get ```csharp @{ // Get the page using it's id - var content = contentService.GetById(1234); + var content = ContentService.GetById(1234); } ``` -If Modelsbuilder is enabled you can get the alias of the desired property without using a magic string: - -{% include "../../../../.gitbook/includes/obsolete-warning-ipublishedsnapshotaccessor.md" %} +If Models Builder is enabled you can get the alias of the desired property without using a magic string: ```csharp -@using Umbraco.Cms.Core.PublishedCache; -@inject IPublishedSnapshotAccessor _publishedSnapshotAccessor; +@using Umbraco.Cms.Core.PublishedCache +@inject IPublishedContentTypeCache PublishedContentTypeCache @{ // Set the value of the property with alias 'datePicker' - content.SetValue(Home.GetModelPropertyType(_publishedSnapshotAccessor, x => x.DatePicker).Alias, DateTime.Now); + content.SetValue(Home.GetModelPropertyType(PublishedContentTypeCache, x => x.DatePicker).Alias, DateTime.Now); } ``` diff --git a/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/decimal.md b/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/decimal.md index 069f5f13722..518b6d4ce3d 100644 --- a/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/decimal.md +++ b/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/decimal.md @@ -22,13 +22,13 @@ If the value of **Step Size** is not set then all decimal values between 8 and 1 ## MVC View Example -### With Modelsbuilder +### With Models Builder ```csharp @Model.MyDecimal ``` -### Without Modelsbuilder +### Without Models Builder ```csharp @Model.Value("MyDecimal") @@ -43,23 +43,20 @@ The example below demonstrates how to add values programmatically using a Razor {% endhint %} ```csharp -@inject IContentService Services; -@using Umbraco.Cms.Core.Services; +@using Umbraco.Cms.Core.Services +@inject IContentService ContentService @{ - // Get access to ContentService - var contentService = Services; - // Create a variable for the GUID of the page you want to update var guid = Guid.Parse("32e60db4-1283-4caa-9645-f2153f9888ef"); // Get the page using the GUID you've defined - var content = contentService.GetById(guid); // ID of your page + var content = ContentService.GetById(guid); // ID of your page // Set the value of the property with alias 'myDecimal'. content.SetValue("myDecimal", 3); // Save the change - contentService.Save(content); + ContentService.Save(content); } ``` @@ -68,19 +65,17 @@ Although the use of a GUID is preferable, you can also use the numeric ID to get ```csharp @{ // Get the page using it's id - var content = contentService.GetById(1234); + var content = ContentService.GetById(1234); } ``` -If Modelsbuilder is enabled you can get the alias of the desired property without using a magic string: - -{% include "../../../../.gitbook/includes/obsolete-warning-ipublishedsnapshotaccessor.md" %} +If Models Builder is enabled you can get the alias of the desired property without using a magic string: ```csharp -@inject IPublishedSnapshotAccessor _publishedSnapshotAccessor; -@using Umbraco.Cms.Core.PublishedCache; +@using Umbraco.Cms.Core.PublishedCache +@inject IPublishedContentTypeCache PublishedContentTypeCache @{ // Set the value of the property with alias 'myDecimal' - content.SetValue(Home.GetModelPropertyType(_publishedSnapshotAccessor, x => x.MyDecimal).Alias, 3); + content.SetValue(Home.GetModelPropertyType(PublishedContentTypeCache, x => x.MyDecimal).Alias, 3); } ``` diff --git a/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/document-picker.md b/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/document-picker.md index cf312983c59..5f919303c6d 100644 --- a/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/document-picker.md +++ b/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/document-picker.md @@ -26,7 +26,7 @@ The change was made as the word **Content** in the backoffice acts as an umbrell ## MVC View Example -### Without Modelsbuilder +### Without Models Builder ```csharp @{ @@ -38,7 +38,7 @@ The change was made as the word **Content** in the backoffice acts as an umbrell } ``` -### With Modelsbuilder +### With Models Builder ```csharp @{ @@ -59,18 +59,15 @@ The example below demonstrates how to add values programmatically using a Razor {% endhint %} ```csharp -@using Umbraco.Cms.Core.Services; - -@inject IContentService Services; +@using Umbraco.Cms.Core +@using Umbraco.Cms.Core.Services +@inject IContentService ContentService @{ - // Get access to ContentService - var contentService = Services; - // Create a variable for the GUID of the page you want to update var guid = Guid.Parse("32e60db4-1283-4caa-9645-f2153f9888ef"); // Get the page using the GUID you've defined - var content = contentService.GetById(guid); // ID of your page + var content = ContentService.GetById(guid); // ID of your page // Get the page you want to assign to the document picker var page = Umbraco.Content("665d7368-e43e-4a83-b1d4-43853860dc45"); @@ -82,7 +79,7 @@ The example below demonstrates how to add values programmatically using a Razor content.SetValue("featurePicker", udi.ToString()); // Save the change - contentService.Save(content); + ContentService.Save(content); } ``` @@ -91,21 +88,17 @@ Although the use of a GUID is preferable, you can also use the numeric ID to get ```csharp @{ // Get the page using it's id - var content = contentService.GetById(1234); + var content = ContentService.GetById(1234); } ``` -If Modelsbuilder is enabled you can get the alias of the desired property without using a magic string: - -{% include "../../../../.gitbook/includes/obsolete-warning-ipublishedsnapshotaccessor.md" %} +If Models Builder is enabled you can get the alias of the desired property without using a magic string: ```csharp -@using Umbraco.Cms.Core.PublishedCache; -@using Umbraco.Cms.Core; - -@inject IPublishedSnapshotAccessor _publishedSnapshotAccessor; +@using Umbraco.Cms.Core.PublishedCache +@inject IPublishedContentTypeCache PublishedContentTypeCache @{ // Set the value of the property with alias 'featurePicker' - content.SetValue(Home.GetModelPropertyType(_publishedSnapshotAccessor, x => x.FeaturePicker).Alias, udi.ToString()); + content.SetValue(Home.GetModelPropertyType(PublishedContentTypeCache, x => x.FeaturePicker).Alias, udi.ToString()); } ``` diff --git a/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/dropdown/README.md b/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/dropdown/README.md index 965dfd2afe5..6eaba1e2b85 100644 --- a/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/dropdown/README.md +++ b/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/dropdown/README.md @@ -38,7 +38,7 @@ You can use dictionary items to translate the options in a Dropdown property edi ## MVC View Example -### Single item - without Modelsbuilder +### Single item - without Models Builder ```csharp @if (Model.HasValue("category")) @@ -47,7 +47,7 @@ You can use dictionary items to translate the options in a Dropdown property edi } ``` -### Multiple items - without Modelsbuilder +### Multiple items - without Models Builder ```csharp @if (Model.HasValue("categories")) @@ -62,7 +62,7 @@ You can use dictionary items to translate the options in a Dropdown property edi } ``` -### Single item - with Modelsbuilder +### Single item - with Models Builder ```csharp @if (!Model.HasValue(Model.Category)) @@ -71,7 +71,7 @@ You can use dictionary items to translate the options in a Dropdown property edi } ``` -### Multiple items - with Modelsbuilder +### Multiple items - with Models Builder ```csharp @if (Model.Categories.Any()) @@ -94,25 +94,22 @@ The example below demonstrates how to add values programmatically using a Razor {% endhint %} ```csharp -@using Umbraco.Cms.Core.Services; -@inject IContentService Services; @using Umbraco.Cms.Core.Serialization -@inject IJsonSerializer Serializer; +@using Umbraco.Cms.Core.Services +@inject IContentService ContentService +@inject IJsonSerializer Serializer @{ - // Get access to ContentService - var contentService = Services; - // Create a variable for the GUID of the page you want to update var guid = Guid.Parse("32e60db4-1283-4caa-9645-f2153f9888ef"); // Get the page using the GUID you've defined - var content = contentService.GetById(guid); // ID of your page + var content = ContentService.GetById(guid); // ID of your page // Set the value of the property with alias 'categories'. content.SetValue("categories", Serializer.Serialize(new[] { "News" })); // Save the change - contentService.Save(content); + ContentService.Save(content); } ``` @@ -121,19 +118,17 @@ Although the use of a GUID is preferable, you can also use the numeric ID to get ```csharp @{ // Get the page using it's id - var content = contentService.GetById(1234); + var content = ContentService.GetById(1234); } ``` -If Modelsbuilder is enabled you can get the alias of the desired property without using a magic string: - -{% include "../../../../../.gitbook/includes/obsolete-warning-ipublishedsnapshotaccessor.md" %} +If Models Builder is enabled you can get the alias of the desired property without using a magic string: ```csharp -@using Umbraco.Cms.Core.PublishedCache; -@inject IPublishedSnapshotAccessor _publishedSnapshotAccessor; +@using Umbraco.Cms.Core.PublishedCache +@inject IPublishedContentTypeCache PublishedContentTypeCache @{ // Set the value of the property with alias 'categories' - content.SetValue(Home.GetModelPropertyType(_publishedSnapshotAccessor, x => x.Categories).Alias, Serializer.Serialize(new[] { "News" })); + content.SetValue(Home.GetModelPropertyType(PublishedContentTypeCache, x => x.Categories).Alias, Serializer.Serialize(new[] { "News" })); } ``` diff --git a/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/eye-dropper-color-picker.md b/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/eye-dropper-color-picker.md index 38430db5703..bca4647fd88 100644 --- a/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/eye-dropper-color-picker.md +++ b/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/eye-dropper-color-picker.md @@ -16,7 +16,7 @@ The Eye Dropper Color picker allows you to choose a color from the full color sp ![Eye Dropper Color Picker Content](images/Eye-Dropper-Color-Picker-Content.png) -## Example with Modelsbuilder +## Example with Models Builder ```csharp @{ @@ -29,7 +29,7 @@ The Eye Dropper Color picker allows you to choose a color from the full color sp } ``` -## Example without Modelsbuilder +## Example without Models Builder ```csharp @{ @@ -51,23 +51,20 @@ The example below demonstrates how to add values programmatically using a Razor {% endhint %} ```csharp -@using Umbraco.Cms.Core.Services; -@inject IContentService Services; +@using Umbraco.Cms.Core.Services +@inject IContentService ContentService @{ - // Get access to ContentService - var contentService = Services; - // Create a variable for the GUID of the page you want to update var guid = Guid.Parse("32e60db4-1283-4caa-9645-f2153f9888ef"); // Get the page using the GUID you've defined - var content = contentService.GetById(guid); // ID of your page + var content = ContentService.GetById(guid); // ID of your page // Set the value of the property with alias 'color'. content.SetValue("color", "#6fa8dc"); // Save the change - contentService.Save(content); + ContentService.Save(content); } ``` @@ -76,22 +73,20 @@ Although the use of a GUID is preferable, you can also use the numeric ID to get ```csharp @{ // Get the page using it's id - var content = contentService.GetById(1234); + var content = ContentService.GetById(1234); } ``` -If Modelsbuilder is enabled you can get the alias of the desired property without using a magic string: - -{% include "../../../../.gitbook/includes/obsolete-warning-ipublishedsnapshotaccessor.md" %} +If Models Builder is enabled you can get the alias of the desired property without using a magic string: ```csharp -@using Umbraco.Cms.Core.PublishedCache; -@inject IPublishedSnapshotAccessor _publishedSnapshotAccessor; +@using Umbraco.Cms.Core.PublishedCache +@inject IPublishedContentTypeCache PublishedContentTypeCache @{ // Set the value of the property with alias 'color' - content.SetValue(Home.GetModelPropertyType(_publishedSnapshotAccessor, x => x.Color).Alias, "#6fa8dc"); + content.SetValue(Home.GetModelPropertyType(PublishedContentTypeCache, x => x.Color).Alias, "#6fa8dc"); // Set the value of the property with alias 'theme' - content.SetValue(Home.GetModelPropertyType(_publishedSnapshotAccessor, x => x.Theme).Alias, "rgba(111, 168, 220, 0.7)"); + content.SetValue(Home.GetModelPropertyType(PublishedContentTypeCache, x => x.Theme).Alias, "rgba(111, 168, 220, 0.7)"); } ``` diff --git a/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/file-upload.md b/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/file-upload.md index 962846a7b68..a57c312b4ee 100644 --- a/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/file-upload.md +++ b/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/file-upload.md @@ -30,7 +30,7 @@ Example: `"/media/o01axaqu/guidelines-on-remote-working.pdf"` ## MVC View Example -### Without Modelsbuilder +### Without Models Builder ```csharp @using System.IO; @@ -45,7 +45,7 @@ Example: `"/media/o01axaqu/guidelines-on-remote-working.pdf"` } ``` -### With Modelsbuilder +### With Models Builder ```csharp @if (!Model.HasValue(Model.MyFile)) @@ -72,25 +72,19 @@ The example below demonstrates how to add values programmatically using a Razor @using Umbraco.Cms.Core.IO @using Umbraco.Cms.Core.Serialization @using Umbraco.Cms.Core.Strings -@inject MediaFileManager _mediaFileManager; -@inject IShortStringHelper _shortStringHelper; -@inject IContentTypeBaseServiceProvider _contentTypeBaseServiceProvider; -@inject IContentService Services; -@inject IJsonSerializer _serializer; -@inject MediaUrlGeneratorCollection _mediaUrlGeneratorCollection; - +@inject MediaFileManager MediaFileManager +@inject IShortStringHelper ShortStringHelper +@inject IContentTypeBaseServiceProvider ContentTypeBaseServiceProvider +@inject IContentService ContentService +@inject IMediaService MediaService +@inject IJsonSerializer Serializer +@inject MediaUrlGeneratorCollection MediaUrlGeneratorCollection @{ - // Get access to ContentService - var contentService = Services; - - // Get access to MediaService - var mediaService = MediaService; - // Create a variable for the GUID of the parent where you want to add a child item var guid = Guid.Parse("32e60db4-1283-4caa-9645-f2153f9888ef"); // Get the page using the GUID you've defined - var content = contentService.GetById(guid); // ID of your page + var content = ContentService.GetById(guid); // ID of your page // Create a variable for the file you want to upload, in this case the Our Umbraco logo var imageUrl = "https://our.umbraco.com/assets/images/logo.svg"; @@ -105,10 +99,10 @@ The example below demonstrates how to add values programmatically using a Razor var filename = imageUrl.Substring(lastIndex, imageUrl.Length - lastIndex); // Create a media file - var media = mediaService.CreateMediaWithIdentity("myImage", -1, "File"); - media.SetValue(_mediaFileManager, _mediaUrlGeneratorCollection, _shortStringHelper, _contentTypeBaseServiceProvider, Constants.Conventions.Media.File, filename, responseStream); + var media = MediaService.CreateMediaWithIdentity("myImage", -1, "File"); + media.SetValue(MediaFileManager, MediaUrlGeneratorCollection, ShortStringHelper, ContentTypeBaseServiceProvider, Constants.Conventions.Media.File, filename, responseStream); // Save the created media - mediaService.Save(media); + MediaService.Save(media); // Get the published version of the media (IPublishedContent) var publishedMedia = Umbraco.Media(media.Id); @@ -117,7 +111,7 @@ The example below demonstrates how to add values programmatically using a Razor content.SetValue("myFile", publishedMedia.Url()); // Save the child item - contentService.Save(content); + ContentService.Save(content); } ``` @@ -126,18 +120,17 @@ Although the use of a GUID is preferable, you can also use the numeric ID to get ```csharp @{ // Get the page using it's id - var content = contentService.GetById(1234); + var content = ContentService.GetById(1234); } ``` -If Modelsbuilder is enabled you can get the alias of the desired property without using a magic string: - -{% include "../../../../.gitbook/includes/obsolete-warning-ipublishedsnapshotaccessor.md" %} +If Models Builder is enabled you can get the alias of the desired property without using a magic string: ```csharp -@inject IPublishedSnapshotAccessor _publishedSnapshotAccessor; +@using Umbraco.Cms.Core.PublishedCache +@inject IPublishedContentTypeCache PublishedContentTypeCache @{ // Set the value of the property with alias 'myFile' - content.SetValue(Home.GetModelPropertyType(_publishedSnapshotAccessor, x => x.MyFile).Alias, publishedMedia.Url(); + content.SetValue(Home.GetModelPropertyType(PublishedContentTypeCache, x => x.MyFile).Alias, publishedMedia.Url(); } ``` diff --git a/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/label.md b/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/label.md index 1c9043287aa..d8b2656e1a3 100644 --- a/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/label.md +++ b/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/label.md @@ -24,7 +24,7 @@ There is also a Value Type: Long string if you need to set a long string value f ## MVC View Example -### Without ModelsBuilder +### Without Models Builder ```csharp @{ @@ -34,7 +34,7 @@ There is also a Value Type: Long string if you need to set a long string value f } ``` -### With ModelsBuilder +### With Models Builder ```csharp @{ @@ -54,23 +54,20 @@ The example below demonstrates how to add values programmatically using a Razor {% endhint %} ```csharp +@using Umbraco.Cms.Core.Services +@inject IContentService ContentService @{ - @inject IContentService Services; + // Create a variable for the GUID of the page you want to update + var guid = Guid.Parse("32e60db4-1283-4caa-9645-f2153f9888ef"); - // Get access to ContentService - var contentService = Services; - - // Create a variable for the GUID of the page you want to update - var guid = Guid.Parse("32e60db4-1283-4caa-9645-f2153f9888ef"); - - // Get the page using the GUID you've defined - var content = contentService.GetById(guid); // ID of your page - - // Set the value of the property with alias 'pageLabel'. - content.SetValue("pageLabel", "A pre-set string value"); - - // Save the change - contentService.Save(content); + // Get the page using the GUID you've defined + var content = ContentService.GetById(guid); // ID of your page + + // Set the value of the property with alias 'pageLabel'. + content.SetValue("pageLabel", "A pre-set string value"); + + // Save the change + ContentService.Save(content); } ``` @@ -79,19 +76,17 @@ Although the use of a GUID is preferable, you can also use the numeric ID to get ```csharp @{ // Get the page using it's id - var content = contentService.GetById(1234); + var content = ContentService.GetById(1234); } ``` -If Modelsbuilder is enabled you can get the alias of the desired property without using a magic string: - -{% include "../../../../.gitbook/includes/obsolete-warning-ipublishedsnapshotaccessor.md" %} +If Models Builder is enabled you can get the alias of the desired property without using a magic string: ```csharp +@using Umbraco.Cms.Core.PublishedCache +@inject IPublishedContentTypeCache PublishedContentTypeCache @{ - @inject IPublishedSnapshotAccessor _publishedSnapshotAccessor - // Set the value of the property with alias 'pageLabel' - content.SetValue(Home.GetModelPropertyType(_publishedSnapshotAccessor, x => x.MyLabel).Alias, "A Preset string"); + content.SetValue(Home.GetModelPropertyType(PublishedContentTypeCache, x => x.MyLabel).Alias, "A pre-set string value"); } ``` diff --git a/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/markdown-editor.md b/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/markdown-editor.md index 67c298f50f5..d81bcc68fc6 100644 --- a/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/markdown-editor.md +++ b/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/markdown-editor.md @@ -49,13 +49,13 @@ There are three settings available for manipulating the **Markdown editor** prop ## MVC View Example -### With Modelsbuilder +### With Models Builder ```csharp @Model.MyMarkdownEditor ``` -### Without Modelsbuilder +### Without Models Builder ```csharp @Model.Value("MyMarkdownEditor") @@ -70,17 +70,14 @@ The example below demonstrates how to add values programmatically using a Razor {% endhint %} ```csharp -@using Umbraco.Cms.Core.Services; -@inject IContentService Services; +@using Umbraco.Cms.Core.Services +@inject IContentService ContentService @{ - // Get access to ContentService - var contentService = Services; - // Create a variable for the GUID of the page you want to update var guid = Guid.Parse("32e60db4-1283-4caa-9645-f2153f9888ef"); // Get the page using the GUID you've defined - var content = contentService.GetById(guid); // ID of your page + var content = ContentService.GetById(guid); // ID of your page // Create markdown value var markdownValue = new HtmlString("#heading \n**strong text**"); @@ -89,7 +86,7 @@ The example below demonstrates how to add values programmatically using a Razor content.SetValue("myMarkdownEditor", markdownValue); // Save the change - contentService.Save(content); + ContentService.Save(content); } ``` @@ -98,19 +95,17 @@ Although the use of a GUID is preferable, you can also use the numeric ID to get ```csharp @{ // Get the page using it's id - var content = contentService.GetById(1234); + var content = ContentService.GetById(1234); } ``` -If Modelsbuilder is enabled you can get the alias of the desired property without using a magic string: - -{% include "../../../../.gitbook/includes/obsolete-warning-ipublishedsnapshotaccessor.md" %} +If Models Builder is enabled you can get the alias of the desired property without using a magic string: ```csharp -@using Umbraco.Cms.Core.PublishedCache; -@inject IPublishedSnapshotAccessor _publishedSnapshotAccessor; +@using Umbraco.Cms.Core.PublishedCache +@inject IPublishedContentTypeCache PublishedContentTypeCache @{ // Set the value of the property with alias 'myMarkdownEditor' - content.SetValue(Home.GetModelPropertyType(_publishedSnapshotAccessor, x => x.MyMarkdownEditor).Alias, markdownValue); + content.SetValue(Home.GetModelPropertyType(PublishedContentTypeCache, x => x.MyMarkdownEditor).Alias, markdownValue); } ``` diff --git a/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/media-picker-3.md b/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/media-picker-3.md index 5371ed8c4eb..5114b4f2852 100644 --- a/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/media-picker-3.md +++ b/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/media-picker-3.md @@ -63,7 +63,7 @@ Global crops are configured on the Image Cropper property of the Image Media Typ ## MVC View Example -### Multiple enabled without Modelsbuilder +### Multiple enabled without Models Builder ```csharp @using Umbraco.Cms.Core.Models @@ -76,7 +76,7 @@ Global crops are configured on the Image Cropper property of the Image Media Typ } ``` -#### Multiple enabled without Modelsbuilder to retrieve IEnumerable data +#### Multiple enabled without Models Builder to retrieve IEnumerable data ```csharp @using Umbraco.Cms.Core.Models @@ -93,7 +93,7 @@ Global crops are configured on the Image Cropper property of the Image Media Typ While `MediaWithCrops` is the default return type, `IPublishedContent` may be used in backward-compatible implementations or when working directly with core APIs. {% endhint %} -### Multiple enabled with Modelsbuilder +### Multiple enabled with Models Builder ```csharp @{ @@ -105,7 +105,7 @@ While `MediaWithCrops` is the default return type, `IPublishedContent` may be us } ``` -### Multiple disabled without Modelsbuilder +### Multiple disabled without Models Builder ```csharp @using Umbraco.Cms.Core.Models @@ -118,7 +118,7 @@ While `MediaWithCrops` is the default return type, `IPublishedContent` may be us } ``` -### Multiple disabled with Modelsbuilder +### Multiple disabled with Models Builder ```csharp @using Umbraco.Cms.Core.Models @@ -170,18 +170,15 @@ The example below demonstrates how to add values programmatically using a Razor {% endhint %} ```csharp -@using Umbraco.Cms.Core; -@using Umbraco.Cms.Core.Services; -@inject IContentService Services; +@using Umbraco.Cms.Core +@using Umbraco.Cms.Core.Services +@inject IContentService ContentService @{ - // Get access to ContentService - var contentService = Services; - // Create a variable for the GUID of the page you want to update var guid = Guid.Parse("32e60db4-1283-4caa-9645-f2153f9888ef"); // Get the page using the GUID you've defined - var content = contentService.GetById(guid); // ID of your page + var content = ContentService.GetById(guid); // ID of your page // Get the media you want to assign to the media picker var media = Umbraco.Media("bca8d5fa-de0a-4f2b-9520-02118d8329a8"); @@ -193,7 +190,7 @@ The example below demonstrates how to add values programmatically using a Razor content.SetValue("featuredBanner", udi.ToString()); // Save the change - contentService.Save(content); + ContentService.Save(content); } ``` @@ -202,19 +199,17 @@ Although the use of a GUID is preferable, you can also use the numeric ID to get ```csharp @{ // Get the page using it's id - var content = contentService.GetById(1234); + var content = ContentService.GetById(1234); } ``` -If Modelsbuilder is enabled you can get the alias of the desired property without using a magic string: - -{% include "../../../../.gitbook/includes/obsolete-warning-ipublishedsnapshotaccessor.md" %} +If Models Builder is enabled you can get the alias of the desired property without using a magic string: ```csharp -@using Umbraco.Cms.Core.PublishedCache; -@inject IPublishedSnapshotAccessor _publishedSnapshotAccessor; +@using Umbraco.Cms.Core.PublishedCache +@inject IPublishedContentTypeCache PublishedContentTypeCache @{ // Set the value of the property with alias 'featuredBanner' - content.SetValue(Home.GetModelPropertyType(_publishedSnapshotAccessor, x => x.FeaturedBanner).Alias, udi.ToString()); + content.SetValue(Home.GetModelPropertyType(PublishedContentTypeCache, x => x.FeaturedBanner).Alias, udi.ToString()); } ``` diff --git a/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/member-group-picker.md b/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/member-group-picker.md index 7799b66b1f1..234645e6e4a 100644 --- a/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/member-group-picker.md +++ b/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/member-group-picker.md @@ -18,7 +18,7 @@ The Member Group Picker opens a panel to pick one or more member groups from the ## MVC View Example -### Without Modelsbuilder +### Without Models Builder ```csharp @if (Model.HasValue("memberGroup")) @@ -28,7 +28,7 @@ The Member Group Picker opens a panel to pick one or more member groups from the } ``` -### With Modelsbuilder +### With Models Builder ```csharp @if (!string.IsNullOrEmpty(Model.MemberGroup)) @@ -46,24 +46,20 @@ The example below demonstrates how to add values programmatically using a Razor {% endhint %} ```csharp -@using Umbraco.Cms.Core.Services; - -@inject IContentService Services; +@using Umbraco.Cms.Core.Services +@inject IContentService ContentService @{ - // Get access to ContentService - var contentService = Services; - // Create a variable for the GUID of the page you want to update var guid = new Guid("796a8d5c-b7bb-46d9-bc57-ab834d0d1248"); // Get the page using the GUID you've defined - var content = contentService.GetById(guid); // ID of your page + var content = ContentService.GetById(guid); // ID of your page // Set the value of the property with alias 'memberGroup'. The value is the specific ID of the member group content.SetValue("memberGroup", 1067); // Save the change - contentService.Save(content); + ContentService.Save(content); } ``` @@ -81,21 +77,17 @@ Although the use of a GUID is preferable, you can also use the numeric ID to get ```csharp @{ // Get the page using it's id - var content = contentService.GetById(1234); + var content = ContentService.GetById(1234); } ``` -If Modelsbuilder is enabled you can get the alias of the desired property without using a magic string: - -{% include "../../../../.gitbook/includes/obsolete-warning-ipublishedsnapshotaccessor.md" %} +If Models Builder is enabled you can get the alias of the desired property without using a magic string: ```csharp -@using Umbraco.Cms.Core.PublishedCache; -@using Umbraco.Cms.Core; - -@inject IPublishedSnapshotAccessor _publishedSnapshotAccessor; +@using Umbraco.Cms.Core.PublishedCache +@inject IPublishedContentTypeCache PublishedContentTypeCache @{ // Set the value of the property with alias 'memberGroup' - content.SetValue(Home.GetModelPropertyType(_publishedSnapshotAccessor, x => x.MemberGroup).Alias, 1067); + content.SetValue(Home.GetModelPropertyType(PublishedContentTypeCache, x => x.MemberGroup).Alias, 1067); } ``` diff --git a/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/member-picker.md b/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/member-picker.md index a39b0b3aca7..bbe672ae2fe 100644 --- a/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/member-picker.md +++ b/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/member-picker.md @@ -18,7 +18,7 @@ The member picker opens a panel to pick a specific member from the member sectio ## MVC View Example -### Without Modelsbuilder +### Without Models Builder ```csharp @{ @@ -30,7 +30,7 @@ The member picker opens a panel to pick a specific member from the member sectio } ``` -### With Modelsbuilder +### With Models Builder ```csharp @{ @@ -51,18 +51,14 @@ The example below demonstrates how to add values programmatically using a Razor {% endhint %} ```csharp -@using Umbraco.Cms.Core.Services; - -@inject IContentService Services; +@using Umbraco.Cms.Core.Services +@inject IContentService ContentService @{ - // Get access to ContentService - var contentService = Services; - // Create a variable for the GUID of the page you want to update var guid = Guid.Parse("32e60db4-1283-4caa-9645-f2153f9888ef"); // Get the page using the GUID you've defined - var content = contentService.GetById(guid); // ID of your page + var content = ContentService.GetById(guid); // ID of your page // Create a variable for the GUID of the member ID var authorId = Guid.Parse("ed944097281e4492bcdf783355219450"); @@ -71,7 +67,7 @@ The example below demonstrates how to add values programmatically using a Razor content.SetValue("author", authorId); // Save the change - contentService.Save(content); + ContentService.Save(content); } ``` @@ -80,23 +76,17 @@ Although the use of a GUID is preferable, you can also use the numeric ID to get ```csharp @{ // Get the page using it's id - var content = contentService.GetById(1234); + var content = ContentService.GetById(1234); } ``` -If Modelsbuilder is enabled you can get the alias of the desired property without using a magic string: - -{% include "../../../../.gitbook/includes/obsolete-warning-ipublishedsnapshotaccessor.md" %} +If Models Builder is enabled you can get the alias of the desired property without using a magic string: ```csharp -@using Umbraco.Cms.Core.PublishedCache; -@using Umbraco.Cms.Core; - -@inject IPublishedSnapshotAccessor _publishedSnapshotAccessor; +@using Umbraco.Cms.Core.PublishedCache +@inject IPublishedContentTypeCache PublishedContentTypeCache @{ - var udi = Udi.Create(Constants.UdiEntityType.Member, authorId); - // Set the value of the property with alias 'author' - content.SetValue(Home.GetModelPropertyType(_publishedSnapshotAccessor, x => x.Author).Alias, udi); + content.SetValue(Home.GetModelPropertyType(PublishedContentTypeCache, x => x.Author).Alias, udi); } ``` diff --git a/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/multi-url-picker.md b/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/multi-url-picker.md index 7f509db6989..ed6d10a7330 100644 --- a/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/multi-url-picker.md +++ b/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/multi-url-picker.md @@ -58,21 +58,18 @@ The example below demonstrates how to add values programmatically using a Razor {% endhint %} ```csharp -@using Umbraco.Cms.Core; +@using Umbraco.Cms.Core @using Umbraco.Cms.Core.Serialization -@using Umbraco.Cms.Core.Services; -@using Umbraco.Cms.Core.Models; -@inject IContentService Services; -@inject IJsonSerializer Serializer; +@using Umbraco.Cms.Core.Services +@using Umbraco.Cms.Core.Models +@inject IContentService ContentService +@inject IJsonSerializer Serializer @{ - // Get access to ContentService - var contentService = Services; - // Create a variable for the GUID of the page you want to update var guid = Guid.Parse("32e60db4-1283-4caa-9645-f2153f9888ef"); // Get the page using the GUID you've defined - var content = contentService.GetById(guid); // ID of your page + var content = ContentService.GetById(guid); // ID of your page // Get the media you want to assign to the footer links property var media = Umbraco.Media("bca8d5fa-de0a-4f2b-9520-02118d8329a8"); @@ -125,7 +122,7 @@ The example below demonstrates how to add values programmatically using a Razor content.SetValue("footerLinks", links); // Save the change - contentService.Save(content); + ContentService.Save(content); } ``` @@ -134,19 +131,17 @@ Although the use of a GUID is preferable, you can also use the numeric ID to get ```csharp @{ // Get the page using it's id - var content = contentService.GetById(1234); + var content = ContentService.GetById(1234); } ``` -If Modelsbuilder is enabled you can get the alias of the desired property without using a magic string: - -{% include "../../../../.gitbook/includes/obsolete-warning-ipublishedsnapshotaccessor.md" %} +If Models Builder is enabled you can get the alias of the desired property without using a magic string: ```csharp -@using Umbraco.Cms.Core.PublishedCache; -@inject IPublishedSnapshotAccessor _publishedSnapshotAccessor; +@using Umbraco.Cms.Core.PublishedCache +@inject IPublishedContentTypeCache PublishedContentTypeCache @{ // Set the value of the property with alias 'footerLinks' - content.SetValue(Home.GetModelPropertyType(_publishedSnapshotAccessor, x => x.FooterLinks).Alias, links); + content.SetValue(Home.GetModelPropertyType(PublishedContentTypeCache, x => x.FooterLinks).Alias, links); } ``` diff --git a/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/multiple-textbox.md b/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/multiple-textbox.md index f22ad3a1114..71db7e81462 100644 --- a/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/multiple-textbox.md +++ b/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/multiple-textbox.md @@ -18,7 +18,7 @@ The Repeatable textstrings property editor enables a content editor to make a li ## MVC View Example -### Without Modelsbuilder +### Without Models Builder ```csharp @{ @@ -34,7 +34,7 @@ The Repeatable textstrings property editor enables a content editor to make a li } ``` -### With Modelsbuilder +### With Models Builder ```csharp @{ @@ -59,23 +59,20 @@ The example below demonstrates how to add values programmatically using a Razor {% endhint %} ```csharp -@using Umbraco.Cms.Core.Services; -@inject IContentService Services; +@using Umbraco.Cms.Core.Services +@inject IContentService ContentService @{ - // Get access to ContentService - var contentService = Services; - // Create a variable for the GUID of the page you want to update var guid = new Guid("32e60db4-1283-4caa-9645-f2153f9888ef"); // Get the page using the GUID you've defined - var content = contentService.GetById(guid); // ID of your page + var content = ContentService.GetById(guid); // ID of your page // Set the value of the property with alias 'keyFeatureList' content.SetValue("keyFeatureList", "Awesome" + Environment.NewLine + "Super"); // Save the change - contentService.Save(content); + ContentService.Save(content); } ``` @@ -88,19 +85,17 @@ Although the use of a GUID is preferable, you can also use the numeric ID to get ```csharp @{ // Get the page using it's id - var content = contentService.GetById(1234); + var content = ContentService.GetById(1234); } ``` -If Modelsbuilder is enabled you can get the alias of the desired property without using a magic string: - -{% include "../../../../.gitbook/includes/obsolete-warning-ipublishedsnapshotaccessor.md" %} +If Models Builder is enabled you can get the alias of the desired property without using a magic string: ```csharp -@using Umbraco.Cms.Core.PublishedCache; -@inject IPublishedSnapshotAccessor _publishedSnapshotAccessor; +@using Umbraco.Cms.Core.PublishedCache +@inject IPublishedContentTypeCache PublishedContentTypeCache @{ // Set the value of the property with alias 'keyFeatureList' - content.SetValue(Home.GetModelPropertyType(_publishedSnapshotAccessor, x => x.KeyFeatureList).Alias, "Awesome" + Environment.NewLine + "Super"); + content.SetValue(Home.GetModelPropertyType(PublishedContentTypeCache, x => x.KeyFeatureList).Alias, "Awesome" + Environment.NewLine + "Super"); } ``` diff --git a/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/numeric.md b/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/numeric.md index 806ec75d0f1..facbede1337 100644 --- a/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/numeric.md +++ b/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/numeric.md @@ -32,7 +32,7 @@ This allows you to set up a maximum value. If you will always need a maximum val ## MVC View Examples -### Rendering the output casting to an int (without Modelsbuilder) +### Rendering the output casting to an int (without Models Builder) By casting the output as an int it's possible for you to do mathematical operations with the value. @@ -46,7 +46,7 @@ By casting the output as an int it's possible for you to do mathematical operati } ``` -### Rendering the output casting to a string (Without Modelsbuilder) +### Rendering the output casting to a string (Without Models Builder) You can also render the output by casting it to a string, which means you will not be able to do mathematical operations @@ -58,7 +58,7 @@ You can also render the output by casting it to a string, which means you will n } ``` -### With Modelsbuilder +### With Models Builder ```csharp @{ @@ -79,23 +79,20 @@ The example below demonstrates how to add values programmatically using a Razor {% endhint %} ```csharp -@using Umbraco.Cms.Core.Services; -@inject IContentService Services; +@using Umbraco.Cms.Core.Services +@inject IContentService ContentService @{ - // Get access to ContentService - var contentService = Services; - // Create a variable for the GUID of the page you want to update var guid = new Guid("32e60db4-1283-4caa-9645-f2153f9888ef"); // Get the page using the GUID you've defined - var content = contentService.GetById(guid); // ID of your page + var content = ContentService.GetById(guid); // ID of your page // Set the value of the property with alias 'students' content.SetValue("students", 20); // Save the change - contentService.Save(content); + ContentService.Save(content); } ``` @@ -105,19 +102,17 @@ Although the use of a GUID is preferable, you can also use the numeric ID to get ```csharp @{ // Get the page using it's id - var content = contentService.GetById(1234); + var content = ContentService.GetById(1234); } ``` -If Modelsbuilder is enabled you can get the alias of the desired property without using a magic string: - -{% include "../../../../.gitbook/includes/obsolete-warning-ipublishedsnapshotaccessor.md" %} +If Models Builder is enabled you can get the alias of the desired property without using a magic string: ```csharp -@using Umbraco.Cms.Core.PublishedCache; -@inject IPublishedSnapshotAccessor _publishedSnapshotAccessor; +@using Umbraco.Cms.Core.PublishedCache +@inject IPublishedContentTypeCache PublishedContentTypeCache @{ // Set the value of the property with alias 'students' - content.SetValue(Home.GetModelPropertyType(_publishedSnapshotAccessor, x => x.Students).Alias, 20); + content.SetValue(Home.GetModelPropertyType(PublishedContentTypeCache, x => x.Students).Alias, 20); } ``` diff --git a/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/radiobutton-list.md b/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/radiobutton-list.md index 18596f1dbe0..846d20b90d7 100644 --- a/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/radiobutton-list.md +++ b/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/radiobutton-list.md @@ -24,7 +24,7 @@ You can use dictionary items to translate the values of a Radiobutton List prope ### Typed -#### Without Modelsbuilder +#### Without Models Builder ```csharp @if (Model.HasValue("colorTheme")) @@ -34,7 +34,7 @@ You can use dictionary items to translate the values of a Radiobutton List prope } ``` -#### With Modelsbuilder +#### With Models Builder ```csharp @if (Model.ColorTheme != null) @@ -53,23 +53,20 @@ The example below demonstrates how to add values programmatically using a Razor {% endhint %} ```csharp -@using Umbraco.Cms.Core.Services; -@inject IContentService Services; +@using Umbraco.Cms.Core.Services +@inject IContentService ContentService @{ - // Get access to ContentService - var contentService = Services; - // Create a variable for the GUID of the page you want to update var guid = new Guid("796a8d5c-b7bb-46d9-bc57-ab834d0d1248"); // Get the page using the GUID you've defined - var content = contentService.GetById(guid); // ID of your page + var content = ContentService.GetById(guid); // ID of your page // Set the value of the property with alias 'colorTheme' content.SetValue("colorTheme", "water"); // Save the change - contentService.Save(content); + ContentService.Save(content); } ``` @@ -78,19 +75,17 @@ Although the use of a GUID is preferable, you can also use the numeric ID to get ```csharp @{ // Get the page using it's id - var content = contentService.GetById(1234); + var content = ContentService.GetById(1234); } ``` -If Modelsbuilder is enabled you can get the alias of the desired property without using a magic string: - -{% include "../../../../.gitbook/includes/obsolete-warning-ipublishedsnapshotaccessor.md" %} +If Models Builder is enabled you can get the alias of the desired property without using a magic string: ```csharp -@using Umbraco.Cms.Core.PublishedCache; -@inject IPublishedSnapshotAccessor _publishedSnapshotAccessor; +@using Umbraco.Cms.Core.PublishedCache +@inject IPublishedContentTypeCache PublishedContentTypeCache @{ // Set the value of the property with alias 'colorTheme' - content.SetValue(Home.GetModelPropertyType(_publishedSnapshotAccessor, x => x.ColorTheme).Alias, "water"); + content.SetValue(Home.GetModelPropertyType(PublishedContentTypeCache, x => x.ColorTheme).Alias, "water"); } ``` diff --git a/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/rich-text-editor-tinymce/README.md b/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/rich-text-editor-tinymce/README.md index c0c2f12ff39..44b22d1de54 100644 --- a/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/rich-text-editor-tinymce/README.md +++ b/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/rich-text-editor-tinymce/README.md @@ -49,7 +49,7 @@ Extend the functionality of the Rich Text Editor with plugins. ## MVC View Example -### Without Modelsbuilder +### Without Models Builder ```csharp @{ @@ -59,7 +59,7 @@ Extend the functionality of the Rich Text Editor with plugins. } ``` -### With Modelsbuilder +### With Models Builder ```csharp @{ @@ -79,17 +79,14 @@ The example below demonstrates how to add values programmatically using a Razor {% endhint %} ```csharp -@using Umbraco.Cms.Core.Services; -@inject IContentService Services; +@using Umbraco.Cms.Core.Services +@inject IContentService ContentService @{ - // Get access to ContentService - var contentService = Services; - // Create a variable for the GUID of the page you want to update var guid = Guid.Parse("32e60db4-1283-4caa-9645-f2153f9888ef"); // Get the page using the GUID you've defined - var content = contentService.GetById(guid); // ID of your page + var content = ContentService.GetById(guid); // ID of your page // Create a variable for the desired value var htmlValue = new HtmlString("Add some text here"); @@ -98,7 +95,7 @@ The example below demonstrates how to add values programmatically using a Razor content.SetValue("richText", htmlValue); // Save the change - contentService.Save(content); + ContentService.Save(content); } ``` @@ -107,17 +104,17 @@ Although the use of a GUID is preferable, you can also use the numeric ID to get ```csharp @{ // Get the page using it's id - var content = contentService.GetById(1234); + var content = ContentService.GetById(1234); } ``` -If Modelsbuilder is enabled you can get the alias of the desired property without using a magic string. +If Models Builder is enabled you can get the alias of the desired property without using a magic string. ```csharp -@using Umbraco.Cms.Core.PublishedCache; -@inject IPublishedSnapshotAccessor _publishedSnapshotAccessor; +@using Umbraco.Cms.Core.PublishedCache +@inject IPublishedContentTypeCache PublishedContentTypeCache @{ // Set the value of the property with alias 'richText' - content.SetValue(Home.GetModelPropertyType(_publishedSnapshotAccessor, x => x.RichText).Alias, "Add some text here"); + content.SetValue(Home.GetModelPropertyType(PublishedContentTypeCache, x => x.RichText).Alias, htmlValue); } ``` diff --git a/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/rich-text-editor/README.md b/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/rich-text-editor/README.md index 8c9450cde30..632d9afe185 100644 --- a/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/rich-text-editor/README.md +++ b/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/rich-text-editor/README.md @@ -43,7 +43,7 @@ Extend the functionality of the Rich Text Editor with extensions. ## MVC View Example -### With Modelsbuilder +### With Models Builder ```csharp @{ @@ -54,7 +54,7 @@ Extend the functionality of the Rich Text Editor with extensions. } ``` -### Without Modelsbuilder +### Without Models Builder ```csharp @{ @@ -73,17 +73,14 @@ The example below demonstrates how to add values programmatically using a Razor {% endhint %} ```csharp -@using Umbraco.Cms.Core.Services; -@inject IContentService Services; +@using Umbraco.Cms.Core.Services +@inject IContentService ContentService @{ - // Get access to ContentService - var contentService = Services; - // Create a variable for the GUID of the page you want to update var guid = Guid.Parse("32e60db4-1283-4caa-9645-f2153f9888ef"); // Get the page using the GUID you've defined - var content = contentService.GetById(guid); // ID of your page + var content = ContentService.GetById(guid); // ID of your page // Create a variable for the desired value var htmlValue = new HtmlString("Add some text here"); @@ -92,7 +89,7 @@ The example below demonstrates how to add values programmatically using a Razor content.SetValue("richText", htmlValue); // Save the change - contentService.Save(content); + ContentService.Save(content); } ``` @@ -101,17 +98,17 @@ Although the use of a GUID is preferable, you can also use the numeric ID to get ```csharp @{ // Get the page using it's id - var content = contentService.GetById(1234); + var content = ContentService.GetById(1234); } ``` -If Modelsbuilder is enabled you can get the alias of the desired property without using a magic string. +If Models Builder is enabled you can get the alias of the desired property without using a magic string. ```csharp -@using Umbraco.Cms.Core.PublishedCache; -@inject IPublishedSnapshotAccessor _publishedSnapshotAccessor; +@using Umbraco.Cms.Core.PublishedCache +@inject IPublishedContentTypeCache PublishedContentTypeCache @{ // Set the value of the property with alias 'richText' - content.SetValue(Home.GetModelPropertyType(_publishedSnapshotAccessor, x => x.RichText).Alias, "Add some text here"); + content.SetValue(Home.GetModelPropertyType(PublishedContentTypeCache, x => x.RichText).Alias, htmlValue); } ``` diff --git a/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/slider.md b/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/slider.md index 6865dd46b97..46c977ec3f6 100644 --- a/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/slider.md +++ b/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/slider.md @@ -22,7 +22,7 @@ There are two flavors of the slider. One with a single value picker. One with a ## MVC View Example -### Without Modelsbuilder +### Without Models Builder ```csharp @if (Model.HasValue("singleValueSlider")) @@ -38,7 +38,7 @@ There are two flavors of the slider. One with a single value picker. One with a } ``` -### With Modelsbuilder +### With Models Builder ```csharp // with a range off @@ -68,40 +68,35 @@ The example below demonstrates how to add values programmatically using a Razor ### With a range off ```csharp -@using Umbraco.Cms.Core.Services; -@inject IContentService Services; +@using Umbraco.Cms.Core.Services +@inject IContentService ContentService @{ - // Get access to ContentService - var contentService = Services; - // Create a variable for the GUID of the page you want to update var guid = Guid.Parse("32e60db4-1283-4caa-9645-f2153f9888ef"); // Get the page using the GUID you've defined - var content = contentService.GetById(guid); // ID of your page + var content = ContentService.GetById(guid); // ID of your page // Set the value of the property with alias 'singleValueSlider'. content.SetValue("singleValueSlider", 10); // Save the change - contentService.Save(content); + ContentService.Save(content); } ``` ### With a range on ```csharp -@using Umbraco.Cms.Core.Services; -@inject IContentService Services; +@using Umbraco.Cms.Core.Models +@using Umbraco.Cms.Core.Services +@inject IContentService ContentService @{ - // Get access to ContentService - var contentService = Services; - // Create a variable for the GUID of the page you want to update var guid = Guid.Parse("32e60db4-1283-4caa-9645-f2153f9888ef"); // Get the page using the GUID you've defined - var content = contentService.GetById(guid); // ID of your page + var content = ContentService.GetById(guid); // ID of your page // Create a variable for the desired value of the 'multiValueSlider' property var range = new Range {Minimum = 10, Maximum = 12}; @@ -110,7 +105,7 @@ The example below demonstrates how to add values programmatically using a Razor content.SetValue("multiValueSlider", range); // Save the change - contentService.Save(content); + ContentService.Save(content); } ``` @@ -119,22 +114,20 @@ Although the use of a GUID is preferable, you can also use the numeric ID to get ```csharp @{ // Get the page using it's id - var content = contentService.GetById(1234); + var content = ContentService.GetById(1234); } ``` -If Modelsbuilder is enabled you can get the alias of the desired property without using a magic string: - -{% include "../../../../.gitbook/includes/obsolete-warning-ipublishedsnapshotaccessor.md" %} +If Models Builder is enabled you can get the alias of the desired property without using a magic string: ```csharp -@using Umbraco.Cms.Core.PublishedCache; -@inject IPublishedSnapshotAccessor _publishedSnapshotAccessor; +@using Umbraco.Cms.Core.PublishedCache +@inject IPublishedContentTypeCache PublishedContentTypeCache @{ // Set the value of the property with alias 'singleValueSlider' - content.SetValue(Home.GetModelPropertyType(_publishedSnapshotAccessor, x => x.SingleValueSlider).Alias, 10); + content.SetValue(Home.GetModelPropertyType(PublishedContentTypeCache, x => x.SingleValueSlider).Alias, 10); // Set the value of the property with alias 'multiValueSlider' - content.SetValue(Home.GetModelPropertyType(_publishedSnapshotAccessor, x => x.MultiValueSlider).Alias, new Range {Minimum = 10, Maximum = 12}); + content.SetValue(Home.GetModelPropertyType(PublishedContentTypeCache, x => x.MultiValueSlider).Alias, new Range {Minimum = 10, Maximum = 12}); } ``` diff --git a/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/tags.md b/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/tags.md index ea4daff0403..117c0ed9042 100644 --- a/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/tags.md +++ b/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/tags.md @@ -40,7 +40,7 @@ Whenever a tag has been added it will be visible in the typeahead when you start ## MVC View Example - displays a list of tags -### Multiple items - with Modelsbuilder +### Multiple items - with Models Builder ```csharp @if(Model.Tags.Any()){ @@ -52,7 +52,7 @@ Whenever a tag has been added it will be visible in the typeahead when you start } ``` -### Multiple items - without Modelsbuilder +### Multiple items - without Models Builder ```csharp @if(Model.HasValue("tags")) @@ -78,23 +78,20 @@ The example below demonstrates how to add values programmatically using a Razor ```csharp @using Umbraco.Cms.Core.Serialization @using Umbraco.Cms.Core.Services -@inject IContentService Services; -@inject IJsonSerializer Serializer; +@inject IContentService ContentService +@inject IJsonSerializer Serializer @{ - // Get access to ContentService - var contentService = Services; - // Create a variable for the GUID of the page you want to update var guid = Guid.Parse("9daf8585-6ab6-4ac2-98f0-28bf83aeea6e"); // Get the page using the GUID you've defined - var content = contentService.GetById(guid); // ID of your page + var content = ContentService.GetById(guid); // ID of your page // Set the value of the property with alias 'tags'. content.SetValue("tags", Serializer.Serialize(new[] { "News", "Umbraco", "Example", "Setting Tags", "Helper" })); // Save the change - contentService.Save(content); + ContentService.Save(content); } ``` @@ -103,20 +100,18 @@ Although the use of a GUID is preferable, you can also use the numeric ID to get ```csharp @{ // Get the page using it's id - var content = contentService.GetById(1234); + var content = ContentService.GetById(1234); } ``` -If Modelsbuilder is enabled, you can get the alias of the desired property without using a magic string: - -{% include "../../../../.gitbook/includes/obsolete-warning-ipublishedsnapshotaccessor.md" %} +If Models Builder is enabled, you can get the alias of the desired property without using a magic string: ```csharp -@using Umbraco.Cms.Core.PublishedCache; -@inject IPublishedSnapshotAccessor _publishedSnapshotAccessor; +@using Umbraco.Cms.Core.PublishedCache +@inject IPublishedContentTypeCache PublishedContentTypeCache @{ // Set the value of the property with alias 'tags' - content.SetValue(Home.GetModelPropertyType(_publishedSnapshotAccessor, x => x.Tags).Alias, Serializer.Serialize(new[] { "News", "Umbraco", "Example", "Setting Tags" })); + content.SetValue(Home.GetModelPropertyType(PublishedContentTypeCache, x => x.Tags).Alias, Serializer.Serialize(new[] { "News", "Umbraco", "Example", "Setting Tags" })); } ``` diff --git a/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/textarea.md b/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/textarea.md index e241e536a29..646f6f544e6 100644 --- a/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/textarea.md +++ b/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/textarea.md @@ -26,7 +26,7 @@ Textarea is an HTML textarea control for multiple lines of text. It can be confi ## MVC View Example -### Without Modelsbuilder +### Without Models Builder ```csharp @{ @@ -36,7 +36,7 @@ Textarea is an HTML textarea control for multiple lines of text. It can be confi } ``` -### With Modelsbuilder +### With Models Builder ```csharp @if (!Model.HasValue(Model.Description)) @@ -54,23 +54,20 @@ The example below demonstrates how to add values programmatically using a Razor {% endhint %} ```csharp -@using Umbraco.Cms.Core.Services; -@inject IContentService Services; - +@using Umbraco.Cms.Core.Services +@inject IContentService ContentService @{ - // Get access to ContentService - var contentService = Services; - // Create a variable for the GUID of your page var guid = new Guid("796a8d5c-b7bb-46d9-bc57-ab834d0d1248"); // Get the page using the GUID you've just defined - var content = contentService.GetById(guid); + var content = ContentService.GetById(guid); + // Set the value of the property with alias 'description' content.SetValue("description", "This is some text for the text area!"); // Save the change - contentService.Save(content); + ContentService.Save(content); } ``` @@ -79,20 +76,18 @@ Although the use of a GUID is preferable, you can also use the numeric ID to get ```csharp @{ // Get the page using it's id - var content = contentService.GetById(1234); + var content = ContentService.GetById(1234); } ``` -If Modelsbuilder is enabled you can get the alias of the desired property without using a magic string: - -{% include "../../../../.gitbook/includes/obsolete-warning-ipublishedsnapshotaccessor.md" %} +If Models Builder is enabled you can get the alias of the desired property without using a magic string: ```csharp -@using Umbraco.Cms.Core.PublishedCache; -@inject IPublishedSnapshotAccessor _publishedSnapshotAccessor; +@using Umbraco.Cms.Core.PublishedCache +@inject IPublishedContentTypeCache PublishedContentTypeCache @{ // Set the value of the property with alias 'description' - content.SetValue(Home.GetModelPropertyType(_publishedSnapshotAccessor, x => x.Description).Alias, "This is some text for the text area!"); + content.SetValue(Home.GetModelPropertyType(PublishedContentTypeCache, x => x.Description).Alias, "This is some text for the text area!"); } ``` diff --git a/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/textbox.md b/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/textbox.md index 84cd4b41978..56e56e92d11 100644 --- a/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/textbox.md +++ b/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/textbox.md @@ -28,7 +28,7 @@ Textbox is an HTML input control for text. It can be configured to have a fixed ## MVC View Example -### Without Modelsbuilder +### Without Models Builder ```csharp @{ @@ -40,7 +40,7 @@ Textbox is an HTML input control for text. It can be configured to have a fixed } ``` -### With Modelsbuilder +### With Models Builder ```csharp @{ @@ -62,23 +62,20 @@ The example below demonstrates how to add values programmatically using a Razor {% endhint %} ```csharp -@using Umbraco.Cms.Core.Services; -@inject IContentService Services; +@using Umbraco.Cms.Core.Services +@inject IContentService ContentService @{ - // Get access to ContentService - var contentService = Services; - // Create a variable for the GUID of the page you want to update var guid = new Guid("32e60db4-1283-4caa-9645-f2153f9888ef"); // Get the page using the GUID you've defined - var content = contentService.GetById(guid); // ID of your page + var content = ContentService.GetById(guid); // ID of your page // Set the value of the property with alias 'pageTitle' content.SetValue("pageTitle", "Umbraco Demo"); // Save the change - contentService.Save(content); + ContentService.Save(content); } ``` @@ -87,20 +84,17 @@ Although the use of a GUID is preferable, you can also use the numeric ID to get ```csharp @{ // Get the page using it's id - var content = contentService.GetById(1234); + var content = ContentService.GetById(1234); } ``` -If Modelsbuilder is enabled you can get the alias of the desired property without using a magic string: - -{% include "../../../../.gitbook/includes/obsolete-warning-ipublishedsnapshotaccessor.md" %} +If Models Builder is enabled you can get the alias of the desired property without using a magic string: ```csharp -@using Umbraco.Cms.Core.PublishedCache; -@inject IPublishedSnapshotAccessor _publishedSnapshotAccessor; +@using Umbraco.Cms.Core.PublishedCache +@inject IPublishedContentTypeCache PublishedContentTypeCache @{ - // Set the value of the property with alias 'pageTitle' - content.SetValue(Home.GetModelPropertyType(_publishedSnapshotAccessor, x => x.PageTitle).Alias, "Umbraco Demo"); + content.SetValue(Home.GetModelPropertyType(PublishedContentTypeCache, x => x.PageTitle).Alias, "Umbraco Demo"); } ``` diff --git a/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/true-false.md b/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/true-false.md index 0eb89c9a21e..db185c002a8 100644 --- a/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/true-false.md +++ b/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/true-false.md @@ -22,7 +22,7 @@ It is also possible to define a label, that will be displayed next to the checkb ## MVC View Example -### Without Modelsbuilder +### Without Models Builder ```csharp @{ @@ -33,7 +33,7 @@ It is also possible to define a label, that will be displayed next to the checkb } ``` -### With Modelsbuilder +### With Models Builder ```csharp @{ @@ -53,23 +53,20 @@ The example below demonstrates how to add values programmatically using a Razor {% endhint %} ```csharp -@using Umbraco.Cms.Core.Services; -@inject IContentService Services; +@using Umbraco.Cms.Core.Services +@inject IContentService ContentService @{ - // Get access to ContentService - var contentService = Services; - // Create a variable for the GUID of the page you want to update var guid = new Guid("796a8d5c-b7bb-46d9-bc57-ab834d0d1248"); // Get the page using the GUID you've defined - var content = contentService.GetById(guid); // ID of your page + var content = ContentService.GetById(guid); // ID of your page // Set the value of the property with alias 'myCheckBox' content.SetValue("myCheckBox", true); // Save the change - contentService.Save(content); + ContentService.Save(content); } ``` @@ -78,20 +75,17 @@ Although the use of a GUID is preferable, you can also use the numeric ID to get ```csharp @{ // Get the page using it's id - var content = contentService.GetById(1234); + var content = ContentService.GetById(1234); } ``` -If Modelsbuilder is enabled you can get the alias of the desired property without using a magic string: - -{% include "../../../../.gitbook/includes/obsolete-warning-ipublishedsnapshotaccessor.md" %} +If Models Builder is enabled you can get the alias of the desired property without using a magic string: ```csharp -@using Umbraco.Cms.Core.PublishedCache; -@inject IPublishedSnapshotAccessor _publishedSnapshotAccessor; +@using Umbraco.Cms.Core.PublishedCache +@inject IPublishedContentTypeCache PublishedContentTypeCache @{ // Set the value of the property with alias 'myCheckBox' - content.SetValue(Home.GetModelPropertyType(_publishedSnapshotAccessor,x => x.MyCheckBox).Alias, true); - + content.SetValue(Home.GetModelPropertyType(PublishedContentTypeCache, x => x.MyCheckBox).Alias, true); } ``` diff --git a/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/user-picker.md b/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/user-picker.md index 0c8320c1d93..4a43c573393 100644 --- a/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/user-picker.md +++ b/15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/user-picker.md @@ -22,7 +22,7 @@ The user picker opens a panel to pick a specific user from the Users section. Th Getting the Value of the property will return the user ID - properties of the User can be accessed by referencing UserService. {% endhint %} -### Without Modelsbuilder +### Without Models Builder ```csharp @using Umbraco.Cms.Core.Services; @@ -40,7 +40,7 @@ Getting the Value of the property will return the user ID - properties of the Us } ``` -### With Modelsbuilder +### With Models Builder ```csharp @using Umbraco.Cms.Core.Services; @@ -67,22 +67,20 @@ The example below demonstrates how to add values programmatically using a Razor {% endhint %} ```csharp -@inject IContentService Services; +@using Umbraco.Cms.Core.Services +@inject IContentService ContentService @{ - // Get access to ContentService - var contentService = Services; - // Create a variable for the GUID of the page you want to update var guid = new Guid("796a8d5c-b7bb-46d9-bc57-ab834d0d1248"); // Get the page using the GUID you've defined - var content = contentService.GetById(guid); // ID of your page + var content = ContentService.GetById(guid); // ID of your page // Set the value of the property with alias 'userPicker'. The value is the specific ID of the user content.SetValue("userPicker", -1); // Save the change - contentService.Save(content); + ContentService.Save(content); } ``` @@ -91,18 +89,17 @@ Although the use of a GUID is preferable, you can also use the numeric ID to get ```csharp @{ // Get the page using it's id - var content = contentService.GetById(1234); + var content = ContentService.GetById(1234); } ``` -If Modelsbuilder is enabled you can get the alias of the desired property without using a magic string: - -{% include "../../../../.gitbook/includes/obsolete-warning-ipublishedsnapshotaccessor.md" %} +If Models Builder is enabled you can get the alias of the desired property without using a magic string: ```csharp -@inject IPublishedSnapshotAccessor _publishedSnapshotAccessor; +@using Umbraco.Cms.Core.PublishedCache +@inject IPublishedContentTypeCache PublishedContentTypeCache @{ // Set the value of the property with alias 'userPicker' - content.SetValue(Home.GetModelPropertyType(_publishedSnapshotAccessor, x => x.UserPicker).Alias, "Umbraco Demo"); + content.SetValue(Home.GetModelPropertyType(PublishedContentTypeCache, x => x.UserPicker).Alias, -1); } ``` diff --git a/15/umbraco-cms/fundamentals/backoffice/settings-dashboards.md b/15/umbraco-cms/fundamentals/backoffice/settings-dashboards.md index edfc19505c0..02219eae503 100644 --- a/15/umbraco-cms/fundamentals/backoffice/settings-dashboards.md +++ b/15/umbraco-cms/fundamentals/backoffice/settings-dashboards.md @@ -32,15 +32,10 @@ For more information about Examine Management, see the [Examine Management](../. Published Status -The Published Status dashboard displays the status of your site in the Published Cache Status section alongside the Content and Media nodes value. The Caches section provides three options: Memory Cache, Database Cache, and Internals. +The Published Status dashboard displays the status of your site in the Published Cache Status section alongside the Content and Media nodes value. The Caches section provides two options: -* Memory Cache - Reloads the in-memory cache by entirely reloading it from the database cache. Use it when you think that the memory cache has not been properly refreshed. -* Database Cache - Rebuilds the database cache that is the content of the `cmsContentNu` table. Use it when reloading the Memory Cache is not enough and you think that the database cache has not been properly generated. -* Internals - Lets you trigger a NuCache snapshots collection. - -{% hint style="info"%} -As of Umbraco 15 `IPublishedSnapshot`, `IPublishedSnapshotAccessor`, and `SnapshotCache` are all obsolete. -{%endhint%} +* Reload Memory Cache - Reloads the in-memory cache by from the database cache. Use it when you think that the memory cache has not been properly refreshed. +* Rebuild Database Cache - Rebuilds the database cache - that is, the content of the `cmsContentNu` table. Use it when reloading the Memory Cache is not enough and you think that the database cache has not been properly generated. diff --git a/15/umbraco-cms/reference/templating/modelsbuilder/introduction.md b/15/umbraco-cms/reference/templating/modelsbuilder/introduction.md index 87c7d4a7ab7..843d51c5b29 100644 --- a/15/umbraco-cms/reference/templating/modelsbuilder/introduction.md +++ b/15/umbraco-cms/reference/templating/modelsbuilder/introduction.md @@ -10,14 +10,12 @@ Models can be used anywhere that content is retrieved from the content cache, i. For each content, media and member type in the Umbraco setup, the generator creates a `*.generated.cs` file, corresponding to the type. For instance, a document type with a textstring property named Title, and a rich text editor named BodyText will look like this: -{% include "../../../.gitbook/includes/obsolete-warning-snapshot-publishedcache.md" %} - ```csharp //------------------------------------------------------------------------------ // // This code was generated by a tool. // -// Umbraco.ModelsBuilder.Embedded v9.0.0-beta003+b07f6519e7a1c890b534502982612ce6b3fea293 +// Umbraco.ModelsBuilder.Embedded v15.0.0 // // Changes to this file will be lost if the code is regenerated. // @@ -39,16 +37,18 @@ public partial class NewsItem : PublishedContentModel { // helpers #pragma warning disable 0109 // new is redundant - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "9.0.0-beta003+b07f6519e7a1c890b534502982612ce6b3fea293")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "15.0.0")] public new const string ModelTypeAlias = "newsItem"; - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "9.0.0-beta003+b07f6519e7a1c890b534502982612ce6b3fea293")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "15.0.0")] public new const PublishedItemType ModelItemType = PublishedItemType.Content; - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "9.0.0-beta003+b07f6519e7a1c890b534502982612ce6b3fea293")] - public new static IPublishedContentType GetModelContentType(IPublishedSnapshotAccessor publishedSnapshotAccessor) - => PublishedModelUtility.GetModelContentType(publishedSnapshotAccessor, ModelItemType, ModelTypeAlias); - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "9.0.0-beta003+b07f6519e7a1c890b534502982612ce6b3fea293")] - public static IPublishedPropertyType GetModelPropertyType(IPublishedSnapshotAccessor publishedSnapshotAccessor, Expression> selector) - => PublishedModelUtility.GetModelPropertyType(GetModelContentType(publishedSnapshotAccessor), selector); + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "15.0.0")] + [return: global::System.Diagnostics.CodeAnalysis.MaybeNull] + public new static IPublishedContentType GetModelContentType(IPublishedContentTypeCache contentTypeCache) + => PublishedModelUtility.GetModelContentType(contentTypeCache, ModelItemType, ModelTypeAlias); + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "15.0.0")] + [return: global::System.Diagnostics.CodeAnalysis.MaybeNull] + public static IPublishedPropertyType GetModelPropertyType(IPublishedContentTypeCache contentTypeCache, Expression> selector) + => PublishedModelUtility.GetModelPropertyType(GetModelContentType(contentTypeCache), selector); #pragma warning restore 0109 private IPublishedValueFallback _publishedValueFallback; @@ -65,14 +65,16 @@ public partial class NewsItem : PublishedContentModel /// /// BodyText /// - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "9.0.0-beta003+b07f6519e7a1c890b534502982612ce6b3fea293")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "15.0.0")] + [global::System.Diagnostics.CodeAnalysis.MaybeNull] [ImplementPropertyType("bodyText")] public virtual global::Umbraco.Cms.Core.Strings.IHtmlEncodedString BodyText => this.Value(_publishedValueFallback, "bodyText"); /// /// Title /// - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "9.0.0-beta003+b07f6519e7a1c890b534502982612ce6b3fea293")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "15.0.0")] + [global::System.Diagnostics.CodeAnalysis.MaybeNull] [ImplementPropertyType("title")] public virtual string Title => this.Value(_publishedValueFallback, "title"); } diff --git a/15/umbraco-cms/reference/templating/modelsbuilder/understand-and-extend.md b/15/umbraco-cms/reference/templating/modelsbuilder/understand-and-extend.md index 018e2d6f5d1..5ecccd743c2 100644 --- a/15/umbraco-cms/reference/templating/modelsbuilder/understand-and-extend.md +++ b/15/umbraco-cms/reference/templating/modelsbuilder/understand-and-extend.md @@ -11,8 +11,6 @@ Umbraco’s Models Builder automatically generates strongly typed models for con Models Builder generates each content type as a partial class. For example, a content type named `TextPage` results in a `TextPage.generated.cs` file with a structure like this: -{% include "../../../.gitbook/includes/obsolete-warning-ipublishedsnapshotaccessor.md" %} - ```csharp /// TextPage [PublishedModel("textPage")] @@ -23,11 +21,11 @@ public partial class TextPage : PublishedContentModel public new const PublishedItemType ModelItemType = PublishedItemType.Content; - public new static IPublishedContentType GetModelContentType(IPublishedSnapshotAccessor publishedSnapshotAccessor) - => PublishedModelUtility.GetModelContentType(publishedSnapshotAccessor, ModelItemType, ModelTypeAlias); + public new static IPublishedContentType GetModelContentType(IPublishedContentTypeCache contentTypeCache) + => PublishedModelUtility.GetModelContentType(contentTypeCache, ModelItemType, ModelTypeAlias); - public static IPublishedPropertyType GetModelPropertyType(IPublishedSnapshotAccessor publishedSnapshotAccessor, Expression> selector) - => PublishedModelUtility.GetModelPropertyType(GetModelContentType(publishedSnapshotAccessor), selector); + public static IPublishedPropertyType GetModelPropertyType(IPublishedContentTypeCache contentTypeCache, Expression> selector) + => PublishedModelUtility.GetModelPropertyType(GetModelContentType(contentTypeCache), selector); private IPublishedValueFallback _publishedValueFallback; From 2192ebe1619e7eb9280e7801306e8f077cd18f40 Mon Sep 17 00:00:00 2001 From: kjac Date: Tue, 20 May 2025 10:02:26 +0200 Subject: [PATCH 2/2] Removed IPublishedSnapshotAccessor from V16 code samples --- .../checkbox-list.md | 36 +++++++-------- .../color-picker.md | 38 +++++++--------- .../content-picker.md | 29 +++++------- .../date-time.md | 27 +++++------ .../decimal.md | 27 +++++------ .../document-picker.md | 31 +++++-------- .../dropdown/README.md | 33 ++++++-------- .../eye-dropper-color-picker.md | 29 +++++------- .../file-upload.md | 45 ++++++++----------- .../label.md | 43 ++++++++---------- .../markdown-editor.md | 31 ++++++------- .../media-picker-3.md | 35 +++++++-------- .../member-group-picker.md | 30 +++++-------- .../member-picker.md | 32 +++++-------- .../multi-url-picker.md | 29 +++++------- .../multiple-textbox.md | 27 +++++------ .../numeric.md | 29 +++++------- .../radiobutton-list.md | 27 +++++------ .../rich-text-editor/README.md | 25 +++++------ .../slider.md | 41 +++++++---------- .../built-in-umbraco-property-editors/tags.md | 27 +++++------ .../textarea.md | 29 +++++------- .../textbox.md | 28 +++++------- .../true-false.md | 28 +++++------- .../user-picker.md | 25 +++++------ .../templating/modelsbuilder/introduction.md | 28 ++++++------ .../modelsbuilder/understand-and-extend.md | 10 ++--- 27 files changed, 338 insertions(+), 481 deletions(-) diff --git a/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/checkbox-list.md b/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/checkbox-list.md index c9b965db5c3..a548f410b35 100644 --- a/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/checkbox-list.md +++ b/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/checkbox-list.md @@ -26,7 +26,7 @@ You can use dictionary items to translate the options in a Checkbox List propert ## MVC View Example -### Without Modelsbuilder +### Without Models Builder ```csharp @{ @@ -42,7 +42,7 @@ You can use dictionary items to translate the options in a Checkbox List propert } ``` -### With Modelsbuilder +### With Models Builder ```csharp @{ @@ -67,25 +67,22 @@ The example below demonstrates how to add values programmatically using a Razor {% endhint %} ```csharp -@inject IContentService Services; @using Umbraco.Cms.Core.Serialization -@using Umbraco.Cms.Core.Services; -@inject IJsonSerializer Serializer; +@using Umbraco.Cms.Core.Services +@inject IContentService ContentService +@inject IJsonSerializer Serializer @{ - // Get access to ContentService - var contentService = Services; - // Create a variable for the GUID of the page you want to update var guid = Guid.Parse("32e60db4-1283-4caa-9645-f2153f9888ef"); // Get the page using the GUID you've defined - var content = contentService.GetById(guid); // ID of your page + var content = ContentService.GetById(guid); // ID of your page - // Set the value of the property with alias 'superHeros'. - content.SetValue("superHeros", Serializer.Serialize(new[] { "Umbraco", "CodeGarden"})); + // Set the value of the property with alias 'superHeroes'. + content.SetValue("superHeroes", Serializer.Serialize(new[] { "Umbraco", "CodeGarden"})); // Save the change - contentService.Save(content); + ContentService.Save(content); } ``` @@ -94,20 +91,17 @@ Although the use of a GUID is preferable, you can also use the numeric ID to get ```csharp @{ // Get the page using it's id - var content = contentService.GetById(1234); + var content = ContentService.GetById(1234); } ``` -If Modelsbuilder is enabled you can get the alias of the desired property without using a magic string: - -{% include "../../../../.gitbook/includes/obsolete-warning-ipublishedsnapshotaccessor.md" %} +If Models Builder is enabled you can get the alias of the desired property without using a magic string: ```csharp -@inject IPublishedSnapshotAccessor _publishedSnapshotAccessor; -@using Umbraco.Cms.Core.PublishedCache; +@using Umbraco.Cms.Core.PublishedCache +@inject IPublishedContentTypeCache PublishedContentTypeCache @{ - -// Set the value of the property with alias 'superHeros' -content.SetValue(Home.GetModelPropertyType(_publishedSnapshotAccessor,x => x.SuperHeros).Alias, Serializer.Serialize(new[] { "Umbraco", "CodeGarden"})); + // Set the value of the property with alias 'superHeroes' + content.SetValue(Home.GetModelPropertyType(PublishedContentTypeCache, x => x.SuperHeroes).Alias, Serializer.Serialize(new[] { "Umbraco", "CodeGarden"})); } ``` diff --git a/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/color-picker.md b/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/color-picker.md index f6399f438bd..b98eb924638 100644 --- a/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/color-picker.md +++ b/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/color-picker.md @@ -20,7 +20,7 @@ It is possible to add a label to use with the color. ![Color Picker Content](../../../../../../10/umbraco-cms/fundamentals/backoffice/property-editors/built-in-property-editors/images/Color-Picker-Content-v8.png) -## Example with Modelsbuilder +## Example with Models Builder ```csharp @{ @@ -36,7 +36,7 @@ It is possible to add a label to use with the color. } ``` -## Example without Modelsbuilder +## Example without Models Builder ```csharp @using Umbraco.Cms.Core.PropertyEditors.ValueConverters @@ -64,48 +64,42 @@ The example below demonstrates how to add values programmatically using a Razor ### Without labels ```csharp -@inject IContentService Services; -@using Umbraco.Cms.Core.Services; +@using Umbraco.Cms.Core.Services +@inject IContentService ContentService @{ - // Get access to ContentService - var contentService = Services; - // Create a variable for the GUID of the page you want to update var guid = Guid.Parse("32e60db4-1283-4caa-9645-f2153f9888ef"); // Get the page using the GUID you've defined - var content = contentService.GetById(guid); // ID of your page + var content = ContentService.GetById(guid); // ID of your page // Set the value of the property with alias 'color'. // The value set here, needs to be one of the colors on the Color Picker content.SetValue("color", "38761d"); // Save the change - contentService.Save(content); + ContentService.Save(content); } ``` ### With labels ```csharp -@inject IContentService Services; -@using Umbraco.Cms.Core.Services; +@using Umbraco.Cms.Core.Services +@inject IContentService ContentService @{ - // Get access to ContentService - var contentService = Services; - // Create a variable for the GUID of the page you want to update var guid = Guid.Parse("32e60db4-1283-4caa-9645-f2153f9888ef"); // Get the page using the GUID you've defined - var content = contentService.GetById(guid); // ID of your page + var content = ContentService.GetById(guid); // ID of your page // Set the value of the property with alias 'color'. // The value set here, needs to be one of the colors on the Color Picker content.SetValue("color", "{'value':'000000', 'label':'Black', 'sortOrder':1, 'id':'1'}"); // Save the change - contentService.Save(content); + ContentService.Save(content); } ``` @@ -114,19 +108,17 @@ Although the use of a GUID is preferable, you can also use the numeric ID to get ```csharp @{ // Get the page using it's id - var content = contentService.GetById(1234); + var content = ContentService.GetById(1234); } ``` -If Modelsbuilder is enabled you can get the alias of the desired property without using a magic string: - -{% include "../../../../.gitbook/includes/obsolete-warning-ipublishedsnapshotaccessor.md" %} +If Models Builder is enabled you can get the alias of the desired property without using a magic string: ```csharp -@inject IPublishedSnapshotAccessor _publishedSnapshotAccessor; -@using Umbraco.Cms.Core.PublishedCache; +@using Umbraco.Cms.Core.PublishedCache +@inject IPublishedContentTypeCache PublishedContentTypeCache @{ // Set the value of the property with alias 'color' - content.SetValue(Home.GetModelPropertyType(_publishedSnapshotAccessor, x => x.Color).Alias, "38761d"); + content.SetValue(Home.GetModelPropertyType(PublishedContentTypeCache, x => x.Color).Alias, "38761d"); } ``` diff --git a/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/content-picker.md b/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/content-picker.md index 59f53d6e103..4548605ef3e 100644 --- a/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/content-picker.md +++ b/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/content-picker.md @@ -200,7 +200,7 @@ When opening the picker on the `Umbraco anno MMXXIII` node, it will now show the ## MVC View Example -### Without Modelsbuilder +### Without Models Builder ```csharp @{ @@ -213,7 +213,7 @@ When opening the picker on the `Umbraco anno MMXXIII` node, it will now show the } ``` -### With Modelsbuilder +### With Models Builder ```csharp @{ @@ -234,19 +234,15 @@ The example below demonstrates how to add values programmatically using a Razor {% endhint %} ```csharp -@inject IContentService Services; -@using Umbraco.Cms.Core; +@using Umbraco.Cms.Core @using Umbraco.Cms.Core.Services - +@inject IContentService ContentService @{ - // Get access to ContentService - var contentService = Services; - // Create a variable for the GUID of the page you want to update var guid = Guid.Parse("32e60db4-1283-4caa-9645-f2153f9888ef"); // Get the page using the GUID you've defined - var content = contentService.GetById(guid); // ID of your page + var content = ContentService.GetById(guid); // ID of your page // Get the pages you want to assign to the Content Picker var page = Umbraco.Content("665d7368-e43e-4a83-b1d4-43853860dc45"); @@ -263,7 +259,7 @@ The example below demonstrates how to add values programmatically using a Razor content.SetValue("featuredArticles", string.Join(",", udis)); // Save the change - contentService.Save(content); + ContentService.Save(content); } ``` @@ -272,20 +268,17 @@ Although the use of a GUID is preferable, you can also use the numeric ID to get ```csharp @{ // Get the page using it's id - var content = contentService.GetById(1234); + var content = ContentService.GetById(1234); } ``` -If Modelsbuilder is enabled you can get the alias of the desired property without using a magic string: - -{% include "../../../../.gitbook/includes/obsolete-warning-ipublishedsnapshotaccessor.md" %} +If Models Builder is enabled you can get the alias of the desired property without using a magic string: ```csharp -@inject IPublishedSnapshotAccessor _publishedSnapshotAccessor; -@using Umbraco.Cms.Core.PublishedCache; - +@using Umbraco.Cms.Core.PublishedCache +@inject IPublishedContentTypeCache PublishedContentTypeCache @{ // Set the value of the property with alias 'featuredArticles' - content.SetValue(Home.GetModelPropertyType(_publishedSnapshotAccessor ,x => x.FeaturedArticles).Alias, string.Join(",", udis)); + content.SetValue(Home.GetModelPropertyType(PublishedContentTypeCache, x => x.FeaturedArticles).Alias, string.Join(",", udis)); } ``` diff --git a/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/date-time.md b/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/date-time.md index d566af2ee51..41a6b0bb150 100644 --- a/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/date-time.md +++ b/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/date-time.md @@ -22,13 +22,13 @@ The setting involves defining the format. The default date format in the Umbraco ## MVC View Example - displays a datetime -### With Modelsbuilder +### With Models Builder ```csharp @Model.DatePicker ``` -### Without Modelsbuilder +### Without Models Builder ```csharp @Model.Value("datePicker") @@ -43,23 +43,20 @@ The example below demonstrates how to add values programmatically using a Razor {% endhint %} ```csharp -@inject IContentService Services; -@using Umbraco.Cms.Core.Services; +@using Umbraco.Cms.Core.Services +@inject IContentService ContentService @{ - // Get access to ContentService - var contentService = Services; - // Create a variable for the GUID of the page you want to update var guid = new Guid("32e60db4-1283-4caa-9645-f2153f9888ef"); // Get the page using the GUID you've defined - var content = contentService.GetById(guid); // ID of your page + var content = ContentService.GetById(guid); // ID of your page // Set the value of the property with alias 'datePicker' content.SetValue("datePicker", DateTime.Now); // Save the change - contentService.Save(content); + ContentService.Save(content); } ``` @@ -68,20 +65,18 @@ Although the use of a GUID is preferable, you can also use the numeric ID to get ```csharp @{ // Get the page using it's id - var content = contentService.GetById(1234); + var content = ContentService.GetById(1234); } ``` -If Modelsbuilder is enabled you can get the alias of the desired property without using a magic string: - -{% include "../../../../.gitbook/includes/obsolete-warning-ipublishedsnapshotaccessor.md" %} +If Models Builder is enabled you can get the alias of the desired property without using a magic string: ```csharp -@using Umbraco.Cms.Core.PublishedCache; -@inject IPublishedSnapshotAccessor _publishedSnapshotAccessor; +@using Umbraco.Cms.Core.PublishedCache +@inject IPublishedContentTypeCache PublishedContentTypeCache @{ // Set the value of the property with alias 'datePicker' - content.SetValue(Home.GetModelPropertyType(_publishedSnapshotAccessor, x => x.DatePicker).Alias, DateTime.Now); + content.SetValue(Home.GetModelPropertyType(PublishedContentTypeCache, x => x.DatePicker).Alias, DateTime.Now); } ``` diff --git a/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/decimal.md b/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/decimal.md index 069f5f13722..518b6d4ce3d 100644 --- a/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/decimal.md +++ b/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/decimal.md @@ -22,13 +22,13 @@ If the value of **Step Size** is not set then all decimal values between 8 and 1 ## MVC View Example -### With Modelsbuilder +### With Models Builder ```csharp @Model.MyDecimal ``` -### Without Modelsbuilder +### Without Models Builder ```csharp @Model.Value("MyDecimal") @@ -43,23 +43,20 @@ The example below demonstrates how to add values programmatically using a Razor {% endhint %} ```csharp -@inject IContentService Services; -@using Umbraco.Cms.Core.Services; +@using Umbraco.Cms.Core.Services +@inject IContentService ContentService @{ - // Get access to ContentService - var contentService = Services; - // Create a variable for the GUID of the page you want to update var guid = Guid.Parse("32e60db4-1283-4caa-9645-f2153f9888ef"); // Get the page using the GUID you've defined - var content = contentService.GetById(guid); // ID of your page + var content = ContentService.GetById(guid); // ID of your page // Set the value of the property with alias 'myDecimal'. content.SetValue("myDecimal", 3); // Save the change - contentService.Save(content); + ContentService.Save(content); } ``` @@ -68,19 +65,17 @@ Although the use of a GUID is preferable, you can also use the numeric ID to get ```csharp @{ // Get the page using it's id - var content = contentService.GetById(1234); + var content = ContentService.GetById(1234); } ``` -If Modelsbuilder is enabled you can get the alias of the desired property without using a magic string: - -{% include "../../../../.gitbook/includes/obsolete-warning-ipublishedsnapshotaccessor.md" %} +If Models Builder is enabled you can get the alias of the desired property without using a magic string: ```csharp -@inject IPublishedSnapshotAccessor _publishedSnapshotAccessor; -@using Umbraco.Cms.Core.PublishedCache; +@using Umbraco.Cms.Core.PublishedCache +@inject IPublishedContentTypeCache PublishedContentTypeCache @{ // Set the value of the property with alias 'myDecimal' - content.SetValue(Home.GetModelPropertyType(_publishedSnapshotAccessor, x => x.MyDecimal).Alias, 3); + content.SetValue(Home.GetModelPropertyType(PublishedContentTypeCache, x => x.MyDecimal).Alias, 3); } ``` diff --git a/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/document-picker.md b/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/document-picker.md index cf312983c59..5f919303c6d 100644 --- a/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/document-picker.md +++ b/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/document-picker.md @@ -26,7 +26,7 @@ The change was made as the word **Content** in the backoffice acts as an umbrell ## MVC View Example -### Without Modelsbuilder +### Without Models Builder ```csharp @{ @@ -38,7 +38,7 @@ The change was made as the word **Content** in the backoffice acts as an umbrell } ``` -### With Modelsbuilder +### With Models Builder ```csharp @{ @@ -59,18 +59,15 @@ The example below demonstrates how to add values programmatically using a Razor {% endhint %} ```csharp -@using Umbraco.Cms.Core.Services; - -@inject IContentService Services; +@using Umbraco.Cms.Core +@using Umbraco.Cms.Core.Services +@inject IContentService ContentService @{ - // Get access to ContentService - var contentService = Services; - // Create a variable for the GUID of the page you want to update var guid = Guid.Parse("32e60db4-1283-4caa-9645-f2153f9888ef"); // Get the page using the GUID you've defined - var content = contentService.GetById(guid); // ID of your page + var content = ContentService.GetById(guid); // ID of your page // Get the page you want to assign to the document picker var page = Umbraco.Content("665d7368-e43e-4a83-b1d4-43853860dc45"); @@ -82,7 +79,7 @@ The example below demonstrates how to add values programmatically using a Razor content.SetValue("featurePicker", udi.ToString()); // Save the change - contentService.Save(content); + ContentService.Save(content); } ``` @@ -91,21 +88,17 @@ Although the use of a GUID is preferable, you can also use the numeric ID to get ```csharp @{ // Get the page using it's id - var content = contentService.GetById(1234); + var content = ContentService.GetById(1234); } ``` -If Modelsbuilder is enabled you can get the alias of the desired property without using a magic string: - -{% include "../../../../.gitbook/includes/obsolete-warning-ipublishedsnapshotaccessor.md" %} +If Models Builder is enabled you can get the alias of the desired property without using a magic string: ```csharp -@using Umbraco.Cms.Core.PublishedCache; -@using Umbraco.Cms.Core; - -@inject IPublishedSnapshotAccessor _publishedSnapshotAccessor; +@using Umbraco.Cms.Core.PublishedCache +@inject IPublishedContentTypeCache PublishedContentTypeCache @{ // Set the value of the property with alias 'featurePicker' - content.SetValue(Home.GetModelPropertyType(_publishedSnapshotAccessor, x => x.FeaturePicker).Alias, udi.ToString()); + content.SetValue(Home.GetModelPropertyType(PublishedContentTypeCache, x => x.FeaturePicker).Alias, udi.ToString()); } ``` diff --git a/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/dropdown/README.md b/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/dropdown/README.md index 965dfd2afe5..6eaba1e2b85 100644 --- a/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/dropdown/README.md +++ b/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/dropdown/README.md @@ -38,7 +38,7 @@ You can use dictionary items to translate the options in a Dropdown property edi ## MVC View Example -### Single item - without Modelsbuilder +### Single item - without Models Builder ```csharp @if (Model.HasValue("category")) @@ -47,7 +47,7 @@ You can use dictionary items to translate the options in a Dropdown property edi } ``` -### Multiple items - without Modelsbuilder +### Multiple items - without Models Builder ```csharp @if (Model.HasValue("categories")) @@ -62,7 +62,7 @@ You can use dictionary items to translate the options in a Dropdown property edi } ``` -### Single item - with Modelsbuilder +### Single item - with Models Builder ```csharp @if (!Model.HasValue(Model.Category)) @@ -71,7 +71,7 @@ You can use dictionary items to translate the options in a Dropdown property edi } ``` -### Multiple items - with Modelsbuilder +### Multiple items - with Models Builder ```csharp @if (Model.Categories.Any()) @@ -94,25 +94,22 @@ The example below demonstrates how to add values programmatically using a Razor {% endhint %} ```csharp -@using Umbraco.Cms.Core.Services; -@inject IContentService Services; @using Umbraco.Cms.Core.Serialization -@inject IJsonSerializer Serializer; +@using Umbraco.Cms.Core.Services +@inject IContentService ContentService +@inject IJsonSerializer Serializer @{ - // Get access to ContentService - var contentService = Services; - // Create a variable for the GUID of the page you want to update var guid = Guid.Parse("32e60db4-1283-4caa-9645-f2153f9888ef"); // Get the page using the GUID you've defined - var content = contentService.GetById(guid); // ID of your page + var content = ContentService.GetById(guid); // ID of your page // Set the value of the property with alias 'categories'. content.SetValue("categories", Serializer.Serialize(new[] { "News" })); // Save the change - contentService.Save(content); + ContentService.Save(content); } ``` @@ -121,19 +118,17 @@ Although the use of a GUID is preferable, you can also use the numeric ID to get ```csharp @{ // Get the page using it's id - var content = contentService.GetById(1234); + var content = ContentService.GetById(1234); } ``` -If Modelsbuilder is enabled you can get the alias of the desired property without using a magic string: - -{% include "../../../../../.gitbook/includes/obsolete-warning-ipublishedsnapshotaccessor.md" %} +If Models Builder is enabled you can get the alias of the desired property without using a magic string: ```csharp -@using Umbraco.Cms.Core.PublishedCache; -@inject IPublishedSnapshotAccessor _publishedSnapshotAccessor; +@using Umbraco.Cms.Core.PublishedCache +@inject IPublishedContentTypeCache PublishedContentTypeCache @{ // Set the value of the property with alias 'categories' - content.SetValue(Home.GetModelPropertyType(_publishedSnapshotAccessor, x => x.Categories).Alias, Serializer.Serialize(new[] { "News" })); + content.SetValue(Home.GetModelPropertyType(PublishedContentTypeCache, x => x.Categories).Alias, Serializer.Serialize(new[] { "News" })); } ``` diff --git a/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/eye-dropper-color-picker.md b/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/eye-dropper-color-picker.md index 38430db5703..bca4647fd88 100644 --- a/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/eye-dropper-color-picker.md +++ b/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/eye-dropper-color-picker.md @@ -16,7 +16,7 @@ The Eye Dropper Color picker allows you to choose a color from the full color sp ![Eye Dropper Color Picker Content](images/Eye-Dropper-Color-Picker-Content.png) -## Example with Modelsbuilder +## Example with Models Builder ```csharp @{ @@ -29,7 +29,7 @@ The Eye Dropper Color picker allows you to choose a color from the full color sp } ``` -## Example without Modelsbuilder +## Example without Models Builder ```csharp @{ @@ -51,23 +51,20 @@ The example below demonstrates how to add values programmatically using a Razor {% endhint %} ```csharp -@using Umbraco.Cms.Core.Services; -@inject IContentService Services; +@using Umbraco.Cms.Core.Services +@inject IContentService ContentService @{ - // Get access to ContentService - var contentService = Services; - // Create a variable for the GUID of the page you want to update var guid = Guid.Parse("32e60db4-1283-4caa-9645-f2153f9888ef"); // Get the page using the GUID you've defined - var content = contentService.GetById(guid); // ID of your page + var content = ContentService.GetById(guid); // ID of your page // Set the value of the property with alias 'color'. content.SetValue("color", "#6fa8dc"); // Save the change - contentService.Save(content); + ContentService.Save(content); } ``` @@ -76,22 +73,20 @@ Although the use of a GUID is preferable, you can also use the numeric ID to get ```csharp @{ // Get the page using it's id - var content = contentService.GetById(1234); + var content = ContentService.GetById(1234); } ``` -If Modelsbuilder is enabled you can get the alias of the desired property without using a magic string: - -{% include "../../../../.gitbook/includes/obsolete-warning-ipublishedsnapshotaccessor.md" %} +If Models Builder is enabled you can get the alias of the desired property without using a magic string: ```csharp -@using Umbraco.Cms.Core.PublishedCache; -@inject IPublishedSnapshotAccessor _publishedSnapshotAccessor; +@using Umbraco.Cms.Core.PublishedCache +@inject IPublishedContentTypeCache PublishedContentTypeCache @{ // Set the value of the property with alias 'color' - content.SetValue(Home.GetModelPropertyType(_publishedSnapshotAccessor, x => x.Color).Alias, "#6fa8dc"); + content.SetValue(Home.GetModelPropertyType(PublishedContentTypeCache, x => x.Color).Alias, "#6fa8dc"); // Set the value of the property with alias 'theme' - content.SetValue(Home.GetModelPropertyType(_publishedSnapshotAccessor, x => x.Theme).Alias, "rgba(111, 168, 220, 0.7)"); + content.SetValue(Home.GetModelPropertyType(PublishedContentTypeCache, x => x.Theme).Alias, "rgba(111, 168, 220, 0.7)"); } ``` diff --git a/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/file-upload.md b/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/file-upload.md index 962846a7b68..a57c312b4ee 100644 --- a/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/file-upload.md +++ b/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/file-upload.md @@ -30,7 +30,7 @@ Example: `"/media/o01axaqu/guidelines-on-remote-working.pdf"` ## MVC View Example -### Without Modelsbuilder +### Without Models Builder ```csharp @using System.IO; @@ -45,7 +45,7 @@ Example: `"/media/o01axaqu/guidelines-on-remote-working.pdf"` } ``` -### With Modelsbuilder +### With Models Builder ```csharp @if (!Model.HasValue(Model.MyFile)) @@ -72,25 +72,19 @@ The example below demonstrates how to add values programmatically using a Razor @using Umbraco.Cms.Core.IO @using Umbraco.Cms.Core.Serialization @using Umbraco.Cms.Core.Strings -@inject MediaFileManager _mediaFileManager; -@inject IShortStringHelper _shortStringHelper; -@inject IContentTypeBaseServiceProvider _contentTypeBaseServiceProvider; -@inject IContentService Services; -@inject IJsonSerializer _serializer; -@inject MediaUrlGeneratorCollection _mediaUrlGeneratorCollection; - +@inject MediaFileManager MediaFileManager +@inject IShortStringHelper ShortStringHelper +@inject IContentTypeBaseServiceProvider ContentTypeBaseServiceProvider +@inject IContentService ContentService +@inject IMediaService MediaService +@inject IJsonSerializer Serializer +@inject MediaUrlGeneratorCollection MediaUrlGeneratorCollection @{ - // Get access to ContentService - var contentService = Services; - - // Get access to MediaService - var mediaService = MediaService; - // Create a variable for the GUID of the parent where you want to add a child item var guid = Guid.Parse("32e60db4-1283-4caa-9645-f2153f9888ef"); // Get the page using the GUID you've defined - var content = contentService.GetById(guid); // ID of your page + var content = ContentService.GetById(guid); // ID of your page // Create a variable for the file you want to upload, in this case the Our Umbraco logo var imageUrl = "https://our.umbraco.com/assets/images/logo.svg"; @@ -105,10 +99,10 @@ The example below demonstrates how to add values programmatically using a Razor var filename = imageUrl.Substring(lastIndex, imageUrl.Length - lastIndex); // Create a media file - var media = mediaService.CreateMediaWithIdentity("myImage", -1, "File"); - media.SetValue(_mediaFileManager, _mediaUrlGeneratorCollection, _shortStringHelper, _contentTypeBaseServiceProvider, Constants.Conventions.Media.File, filename, responseStream); + var media = MediaService.CreateMediaWithIdentity("myImage", -1, "File"); + media.SetValue(MediaFileManager, MediaUrlGeneratorCollection, ShortStringHelper, ContentTypeBaseServiceProvider, Constants.Conventions.Media.File, filename, responseStream); // Save the created media - mediaService.Save(media); + MediaService.Save(media); // Get the published version of the media (IPublishedContent) var publishedMedia = Umbraco.Media(media.Id); @@ -117,7 +111,7 @@ The example below demonstrates how to add values programmatically using a Razor content.SetValue("myFile", publishedMedia.Url()); // Save the child item - contentService.Save(content); + ContentService.Save(content); } ``` @@ -126,18 +120,17 @@ Although the use of a GUID is preferable, you can also use the numeric ID to get ```csharp @{ // Get the page using it's id - var content = contentService.GetById(1234); + var content = ContentService.GetById(1234); } ``` -If Modelsbuilder is enabled you can get the alias of the desired property without using a magic string: - -{% include "../../../../.gitbook/includes/obsolete-warning-ipublishedsnapshotaccessor.md" %} +If Models Builder is enabled you can get the alias of the desired property without using a magic string: ```csharp -@inject IPublishedSnapshotAccessor _publishedSnapshotAccessor; +@using Umbraco.Cms.Core.PublishedCache +@inject IPublishedContentTypeCache PublishedContentTypeCache @{ // Set the value of the property with alias 'myFile' - content.SetValue(Home.GetModelPropertyType(_publishedSnapshotAccessor, x => x.MyFile).Alias, publishedMedia.Url(); + content.SetValue(Home.GetModelPropertyType(PublishedContentTypeCache, x => x.MyFile).Alias, publishedMedia.Url(); } ``` diff --git a/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/label.md b/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/label.md index 1c9043287aa..d8b2656e1a3 100644 --- a/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/label.md +++ b/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/label.md @@ -24,7 +24,7 @@ There is also a Value Type: Long string if you need to set a long string value f ## MVC View Example -### Without ModelsBuilder +### Without Models Builder ```csharp @{ @@ -34,7 +34,7 @@ There is also a Value Type: Long string if you need to set a long string value f } ``` -### With ModelsBuilder +### With Models Builder ```csharp @{ @@ -54,23 +54,20 @@ The example below demonstrates how to add values programmatically using a Razor {% endhint %} ```csharp +@using Umbraco.Cms.Core.Services +@inject IContentService ContentService @{ - @inject IContentService Services; + // Create a variable for the GUID of the page you want to update + var guid = Guid.Parse("32e60db4-1283-4caa-9645-f2153f9888ef"); - // Get access to ContentService - var contentService = Services; - - // Create a variable for the GUID of the page you want to update - var guid = Guid.Parse("32e60db4-1283-4caa-9645-f2153f9888ef"); - - // Get the page using the GUID you've defined - var content = contentService.GetById(guid); // ID of your page - - // Set the value of the property with alias 'pageLabel'. - content.SetValue("pageLabel", "A pre-set string value"); - - // Save the change - contentService.Save(content); + // Get the page using the GUID you've defined + var content = ContentService.GetById(guid); // ID of your page + + // Set the value of the property with alias 'pageLabel'. + content.SetValue("pageLabel", "A pre-set string value"); + + // Save the change + ContentService.Save(content); } ``` @@ -79,19 +76,17 @@ Although the use of a GUID is preferable, you can also use the numeric ID to get ```csharp @{ // Get the page using it's id - var content = contentService.GetById(1234); + var content = ContentService.GetById(1234); } ``` -If Modelsbuilder is enabled you can get the alias of the desired property without using a magic string: - -{% include "../../../../.gitbook/includes/obsolete-warning-ipublishedsnapshotaccessor.md" %} +If Models Builder is enabled you can get the alias of the desired property without using a magic string: ```csharp +@using Umbraco.Cms.Core.PublishedCache +@inject IPublishedContentTypeCache PublishedContentTypeCache @{ - @inject IPublishedSnapshotAccessor _publishedSnapshotAccessor - // Set the value of the property with alias 'pageLabel' - content.SetValue(Home.GetModelPropertyType(_publishedSnapshotAccessor, x => x.MyLabel).Alias, "A Preset string"); + content.SetValue(Home.GetModelPropertyType(PublishedContentTypeCache, x => x.MyLabel).Alias, "A pre-set string value"); } ``` diff --git a/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/markdown-editor.md b/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/markdown-editor.md index e257590adc0..7b5fa8f532a 100644 --- a/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/markdown-editor.md +++ b/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/markdown-editor.md @@ -49,13 +49,13 @@ There are three settings available for manipulating the **Markdown editor** prop ## MVC View Example -### With Modelsbuilder +### With Models Builder ```csharp @Model.MyMarkdownEditor ``` -### Without Modelsbuilder +### Without Models Builder ```csharp @Model.Value("MyMarkdownEditor") @@ -70,26 +70,23 @@ The example below demonstrates how to add values programmatically using a Razor {% endhint %} ```csharp -@using Umbraco.Cms.Core.Services; -@inject IContentService Services; +@using Umbraco.Cms.Core.Services +@inject IContentService ContentService @{ - // Get access to ContentService - var contentService = Services; - // Create a variable for the GUID of the page you want to update var guid = Guid.Parse("32e60db4-1283-4caa-9645-f2153f9888ef"); // Get the page using the GUID you've defined - var content = contentService.GetById(guid); // ID of your page + var content = ContentService.GetById(guid); // ID of your page // Create markdown value var markdownValue = new HtmlString("#heading \n**strong text**"); - - // Set the value of the property with alias 'myMarkdownEditor'. + + // Set the value of the property with alias 'myMarkdownEditor'. content.SetValue("myMarkdownEditor", markdownValue); // Save the change - contentService.Save(content); + ContentService.Save(content); } ``` @@ -98,19 +95,17 @@ Although the use of a GUID is preferable, you can also use the numeric ID to get ```csharp @{ // Get the page using it's id - var content = contentService.GetById(1234); + var content = ContentService.GetById(1234); } ``` -If Modelsbuilder is enabled you can get the alias of the desired property without using a magic string: - -{% include "../../../../.gitbook/includes/obsolete-warning-ipublishedsnapshotaccessor.md" %} +If Models Builder is enabled you can get the alias of the desired property without using a magic string: ```csharp -@using Umbraco.Cms.Core.PublishedCache; -@inject IPublishedSnapshotAccessor _publishedSnapshotAccessor; +@using Umbraco.Cms.Core.PublishedCache +@inject IPublishedContentTypeCache PublishedContentTypeCache @{ // Set the value of the property with alias 'myMarkdownEditor' - content.SetValue(Home.GetModelPropertyType(_publishedSnapshotAccessor, x => x.MyMarkdownEditor).Alias, markdownValue); + content.SetValue(Home.GetModelPropertyType(PublishedContentTypeCache, x => x.MyMarkdownEditor).Alias, markdownValue); } ``` diff --git a/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/media-picker-3.md b/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/media-picker-3.md index 5371ed8c4eb..5114b4f2852 100644 --- a/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/media-picker-3.md +++ b/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/media-picker-3.md @@ -63,7 +63,7 @@ Global crops are configured on the Image Cropper property of the Image Media Typ ## MVC View Example -### Multiple enabled without Modelsbuilder +### Multiple enabled without Models Builder ```csharp @using Umbraco.Cms.Core.Models @@ -76,7 +76,7 @@ Global crops are configured on the Image Cropper property of the Image Media Typ } ``` -#### Multiple enabled without Modelsbuilder to retrieve IEnumerable data +#### Multiple enabled without Models Builder to retrieve IEnumerable data ```csharp @using Umbraco.Cms.Core.Models @@ -93,7 +93,7 @@ Global crops are configured on the Image Cropper property of the Image Media Typ While `MediaWithCrops` is the default return type, `IPublishedContent` may be used in backward-compatible implementations or when working directly with core APIs. {% endhint %} -### Multiple enabled with Modelsbuilder +### Multiple enabled with Models Builder ```csharp @{ @@ -105,7 +105,7 @@ While `MediaWithCrops` is the default return type, `IPublishedContent` may be us } ``` -### Multiple disabled without Modelsbuilder +### Multiple disabled without Models Builder ```csharp @using Umbraco.Cms.Core.Models @@ -118,7 +118,7 @@ While `MediaWithCrops` is the default return type, `IPublishedContent` may be us } ``` -### Multiple disabled with Modelsbuilder +### Multiple disabled with Models Builder ```csharp @using Umbraco.Cms.Core.Models @@ -170,18 +170,15 @@ The example below demonstrates how to add values programmatically using a Razor {% endhint %} ```csharp -@using Umbraco.Cms.Core; -@using Umbraco.Cms.Core.Services; -@inject IContentService Services; +@using Umbraco.Cms.Core +@using Umbraco.Cms.Core.Services +@inject IContentService ContentService @{ - // Get access to ContentService - var contentService = Services; - // Create a variable for the GUID of the page you want to update var guid = Guid.Parse("32e60db4-1283-4caa-9645-f2153f9888ef"); // Get the page using the GUID you've defined - var content = contentService.GetById(guid); // ID of your page + var content = ContentService.GetById(guid); // ID of your page // Get the media you want to assign to the media picker var media = Umbraco.Media("bca8d5fa-de0a-4f2b-9520-02118d8329a8"); @@ -193,7 +190,7 @@ The example below demonstrates how to add values programmatically using a Razor content.SetValue("featuredBanner", udi.ToString()); // Save the change - contentService.Save(content); + ContentService.Save(content); } ``` @@ -202,19 +199,17 @@ Although the use of a GUID is preferable, you can also use the numeric ID to get ```csharp @{ // Get the page using it's id - var content = contentService.GetById(1234); + var content = ContentService.GetById(1234); } ``` -If Modelsbuilder is enabled you can get the alias of the desired property without using a magic string: - -{% include "../../../../.gitbook/includes/obsolete-warning-ipublishedsnapshotaccessor.md" %} +If Models Builder is enabled you can get the alias of the desired property without using a magic string: ```csharp -@using Umbraco.Cms.Core.PublishedCache; -@inject IPublishedSnapshotAccessor _publishedSnapshotAccessor; +@using Umbraco.Cms.Core.PublishedCache +@inject IPublishedContentTypeCache PublishedContentTypeCache @{ // Set the value of the property with alias 'featuredBanner' - content.SetValue(Home.GetModelPropertyType(_publishedSnapshotAccessor, x => x.FeaturedBanner).Alias, udi.ToString()); + content.SetValue(Home.GetModelPropertyType(PublishedContentTypeCache, x => x.FeaturedBanner).Alias, udi.ToString()); } ``` diff --git a/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/member-group-picker.md b/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/member-group-picker.md index 7799b66b1f1..234645e6e4a 100644 --- a/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/member-group-picker.md +++ b/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/member-group-picker.md @@ -18,7 +18,7 @@ The Member Group Picker opens a panel to pick one or more member groups from the ## MVC View Example -### Without Modelsbuilder +### Without Models Builder ```csharp @if (Model.HasValue("memberGroup")) @@ -28,7 +28,7 @@ The Member Group Picker opens a panel to pick one or more member groups from the } ``` -### With Modelsbuilder +### With Models Builder ```csharp @if (!string.IsNullOrEmpty(Model.MemberGroup)) @@ -46,24 +46,20 @@ The example below demonstrates how to add values programmatically using a Razor {% endhint %} ```csharp -@using Umbraco.Cms.Core.Services; - -@inject IContentService Services; +@using Umbraco.Cms.Core.Services +@inject IContentService ContentService @{ - // Get access to ContentService - var contentService = Services; - // Create a variable for the GUID of the page you want to update var guid = new Guid("796a8d5c-b7bb-46d9-bc57-ab834d0d1248"); // Get the page using the GUID you've defined - var content = contentService.GetById(guid); // ID of your page + var content = ContentService.GetById(guid); // ID of your page // Set the value of the property with alias 'memberGroup'. The value is the specific ID of the member group content.SetValue("memberGroup", 1067); // Save the change - contentService.Save(content); + ContentService.Save(content); } ``` @@ -81,21 +77,17 @@ Although the use of a GUID is preferable, you can also use the numeric ID to get ```csharp @{ // Get the page using it's id - var content = contentService.GetById(1234); + var content = ContentService.GetById(1234); } ``` -If Modelsbuilder is enabled you can get the alias of the desired property without using a magic string: - -{% include "../../../../.gitbook/includes/obsolete-warning-ipublishedsnapshotaccessor.md" %} +If Models Builder is enabled you can get the alias of the desired property without using a magic string: ```csharp -@using Umbraco.Cms.Core.PublishedCache; -@using Umbraco.Cms.Core; - -@inject IPublishedSnapshotAccessor _publishedSnapshotAccessor; +@using Umbraco.Cms.Core.PublishedCache +@inject IPublishedContentTypeCache PublishedContentTypeCache @{ // Set the value of the property with alias 'memberGroup' - content.SetValue(Home.GetModelPropertyType(_publishedSnapshotAccessor, x => x.MemberGroup).Alias, 1067); + content.SetValue(Home.GetModelPropertyType(PublishedContentTypeCache, x => x.MemberGroup).Alias, 1067); } ``` diff --git a/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/member-picker.md b/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/member-picker.md index a39b0b3aca7..bbe672ae2fe 100644 --- a/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/member-picker.md +++ b/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/member-picker.md @@ -18,7 +18,7 @@ The member picker opens a panel to pick a specific member from the member sectio ## MVC View Example -### Without Modelsbuilder +### Without Models Builder ```csharp @{ @@ -30,7 +30,7 @@ The member picker opens a panel to pick a specific member from the member sectio } ``` -### With Modelsbuilder +### With Models Builder ```csharp @{ @@ -51,18 +51,14 @@ The example below demonstrates how to add values programmatically using a Razor {% endhint %} ```csharp -@using Umbraco.Cms.Core.Services; - -@inject IContentService Services; +@using Umbraco.Cms.Core.Services +@inject IContentService ContentService @{ - // Get access to ContentService - var contentService = Services; - // Create a variable for the GUID of the page you want to update var guid = Guid.Parse("32e60db4-1283-4caa-9645-f2153f9888ef"); // Get the page using the GUID you've defined - var content = contentService.GetById(guid); // ID of your page + var content = ContentService.GetById(guid); // ID of your page // Create a variable for the GUID of the member ID var authorId = Guid.Parse("ed944097281e4492bcdf783355219450"); @@ -71,7 +67,7 @@ The example below demonstrates how to add values programmatically using a Razor content.SetValue("author", authorId); // Save the change - contentService.Save(content); + ContentService.Save(content); } ``` @@ -80,23 +76,17 @@ Although the use of a GUID is preferable, you can also use the numeric ID to get ```csharp @{ // Get the page using it's id - var content = contentService.GetById(1234); + var content = ContentService.GetById(1234); } ``` -If Modelsbuilder is enabled you can get the alias of the desired property without using a magic string: - -{% include "../../../../.gitbook/includes/obsolete-warning-ipublishedsnapshotaccessor.md" %} +If Models Builder is enabled you can get the alias of the desired property without using a magic string: ```csharp -@using Umbraco.Cms.Core.PublishedCache; -@using Umbraco.Cms.Core; - -@inject IPublishedSnapshotAccessor _publishedSnapshotAccessor; +@using Umbraco.Cms.Core.PublishedCache +@inject IPublishedContentTypeCache PublishedContentTypeCache @{ - var udi = Udi.Create(Constants.UdiEntityType.Member, authorId); - // Set the value of the property with alias 'author' - content.SetValue(Home.GetModelPropertyType(_publishedSnapshotAccessor, x => x.Author).Alias, udi); + content.SetValue(Home.GetModelPropertyType(PublishedContentTypeCache, x => x.Author).Alias, udi); } ``` diff --git a/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/multi-url-picker.md b/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/multi-url-picker.md index 7f509db6989..ed6d10a7330 100644 --- a/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/multi-url-picker.md +++ b/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/multi-url-picker.md @@ -58,21 +58,18 @@ The example below demonstrates how to add values programmatically using a Razor {% endhint %} ```csharp -@using Umbraco.Cms.Core; +@using Umbraco.Cms.Core @using Umbraco.Cms.Core.Serialization -@using Umbraco.Cms.Core.Services; -@using Umbraco.Cms.Core.Models; -@inject IContentService Services; -@inject IJsonSerializer Serializer; +@using Umbraco.Cms.Core.Services +@using Umbraco.Cms.Core.Models +@inject IContentService ContentService +@inject IJsonSerializer Serializer @{ - // Get access to ContentService - var contentService = Services; - // Create a variable for the GUID of the page you want to update var guid = Guid.Parse("32e60db4-1283-4caa-9645-f2153f9888ef"); // Get the page using the GUID you've defined - var content = contentService.GetById(guid); // ID of your page + var content = ContentService.GetById(guid); // ID of your page // Get the media you want to assign to the footer links property var media = Umbraco.Media("bca8d5fa-de0a-4f2b-9520-02118d8329a8"); @@ -125,7 +122,7 @@ The example below demonstrates how to add values programmatically using a Razor content.SetValue("footerLinks", links); // Save the change - contentService.Save(content); + ContentService.Save(content); } ``` @@ -134,19 +131,17 @@ Although the use of a GUID is preferable, you can also use the numeric ID to get ```csharp @{ // Get the page using it's id - var content = contentService.GetById(1234); + var content = ContentService.GetById(1234); } ``` -If Modelsbuilder is enabled you can get the alias of the desired property without using a magic string: - -{% include "../../../../.gitbook/includes/obsolete-warning-ipublishedsnapshotaccessor.md" %} +If Models Builder is enabled you can get the alias of the desired property without using a magic string: ```csharp -@using Umbraco.Cms.Core.PublishedCache; -@inject IPublishedSnapshotAccessor _publishedSnapshotAccessor; +@using Umbraco.Cms.Core.PublishedCache +@inject IPublishedContentTypeCache PublishedContentTypeCache @{ // Set the value of the property with alias 'footerLinks' - content.SetValue(Home.GetModelPropertyType(_publishedSnapshotAccessor, x => x.FooterLinks).Alias, links); + content.SetValue(Home.GetModelPropertyType(PublishedContentTypeCache, x => x.FooterLinks).Alias, links); } ``` diff --git a/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/multiple-textbox.md b/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/multiple-textbox.md index f22ad3a1114..71db7e81462 100644 --- a/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/multiple-textbox.md +++ b/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/multiple-textbox.md @@ -18,7 +18,7 @@ The Repeatable textstrings property editor enables a content editor to make a li ## MVC View Example -### Without Modelsbuilder +### Without Models Builder ```csharp @{ @@ -34,7 +34,7 @@ The Repeatable textstrings property editor enables a content editor to make a li } ``` -### With Modelsbuilder +### With Models Builder ```csharp @{ @@ -59,23 +59,20 @@ The example below demonstrates how to add values programmatically using a Razor {% endhint %} ```csharp -@using Umbraco.Cms.Core.Services; -@inject IContentService Services; +@using Umbraco.Cms.Core.Services +@inject IContentService ContentService @{ - // Get access to ContentService - var contentService = Services; - // Create a variable for the GUID of the page you want to update var guid = new Guid("32e60db4-1283-4caa-9645-f2153f9888ef"); // Get the page using the GUID you've defined - var content = contentService.GetById(guid); // ID of your page + var content = ContentService.GetById(guid); // ID of your page // Set the value of the property with alias 'keyFeatureList' content.SetValue("keyFeatureList", "Awesome" + Environment.NewLine + "Super"); // Save the change - contentService.Save(content); + ContentService.Save(content); } ``` @@ -88,19 +85,17 @@ Although the use of a GUID is preferable, you can also use the numeric ID to get ```csharp @{ // Get the page using it's id - var content = contentService.GetById(1234); + var content = ContentService.GetById(1234); } ``` -If Modelsbuilder is enabled you can get the alias of the desired property without using a magic string: - -{% include "../../../../.gitbook/includes/obsolete-warning-ipublishedsnapshotaccessor.md" %} +If Models Builder is enabled you can get the alias of the desired property without using a magic string: ```csharp -@using Umbraco.Cms.Core.PublishedCache; -@inject IPublishedSnapshotAccessor _publishedSnapshotAccessor; +@using Umbraco.Cms.Core.PublishedCache +@inject IPublishedContentTypeCache PublishedContentTypeCache @{ // Set the value of the property with alias 'keyFeatureList' - content.SetValue(Home.GetModelPropertyType(_publishedSnapshotAccessor, x => x.KeyFeatureList).Alias, "Awesome" + Environment.NewLine + "Super"); + content.SetValue(Home.GetModelPropertyType(PublishedContentTypeCache, x => x.KeyFeatureList).Alias, "Awesome" + Environment.NewLine + "Super"); } ``` diff --git a/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/numeric.md b/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/numeric.md index 806ec75d0f1..facbede1337 100644 --- a/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/numeric.md +++ b/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/numeric.md @@ -32,7 +32,7 @@ This allows you to set up a maximum value. If you will always need a maximum val ## MVC View Examples -### Rendering the output casting to an int (without Modelsbuilder) +### Rendering the output casting to an int (without Models Builder) By casting the output as an int it's possible for you to do mathematical operations with the value. @@ -46,7 +46,7 @@ By casting the output as an int it's possible for you to do mathematical operati } ``` -### Rendering the output casting to a string (Without Modelsbuilder) +### Rendering the output casting to a string (Without Models Builder) You can also render the output by casting it to a string, which means you will not be able to do mathematical operations @@ -58,7 +58,7 @@ You can also render the output by casting it to a string, which means you will n } ``` -### With Modelsbuilder +### With Models Builder ```csharp @{ @@ -79,23 +79,20 @@ The example below demonstrates how to add values programmatically using a Razor {% endhint %} ```csharp -@using Umbraco.Cms.Core.Services; -@inject IContentService Services; +@using Umbraco.Cms.Core.Services +@inject IContentService ContentService @{ - // Get access to ContentService - var contentService = Services; - // Create a variable for the GUID of the page you want to update var guid = new Guid("32e60db4-1283-4caa-9645-f2153f9888ef"); // Get the page using the GUID you've defined - var content = contentService.GetById(guid); // ID of your page + var content = ContentService.GetById(guid); // ID of your page // Set the value of the property with alias 'students' content.SetValue("students", 20); // Save the change - contentService.Save(content); + ContentService.Save(content); } ``` @@ -105,19 +102,17 @@ Although the use of a GUID is preferable, you can also use the numeric ID to get ```csharp @{ // Get the page using it's id - var content = contentService.GetById(1234); + var content = ContentService.GetById(1234); } ``` -If Modelsbuilder is enabled you can get the alias of the desired property without using a magic string: - -{% include "../../../../.gitbook/includes/obsolete-warning-ipublishedsnapshotaccessor.md" %} +If Models Builder is enabled you can get the alias of the desired property without using a magic string: ```csharp -@using Umbraco.Cms.Core.PublishedCache; -@inject IPublishedSnapshotAccessor _publishedSnapshotAccessor; +@using Umbraco.Cms.Core.PublishedCache +@inject IPublishedContentTypeCache PublishedContentTypeCache @{ // Set the value of the property with alias 'students' - content.SetValue(Home.GetModelPropertyType(_publishedSnapshotAccessor, x => x.Students).Alias, 20); + content.SetValue(Home.GetModelPropertyType(PublishedContentTypeCache, x => x.Students).Alias, 20); } ``` diff --git a/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/radiobutton-list.md b/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/radiobutton-list.md index 18596f1dbe0..846d20b90d7 100644 --- a/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/radiobutton-list.md +++ b/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/radiobutton-list.md @@ -24,7 +24,7 @@ You can use dictionary items to translate the values of a Radiobutton List prope ### Typed -#### Without Modelsbuilder +#### Without Models Builder ```csharp @if (Model.HasValue("colorTheme")) @@ -34,7 +34,7 @@ You can use dictionary items to translate the values of a Radiobutton List prope } ``` -#### With Modelsbuilder +#### With Models Builder ```csharp @if (Model.ColorTheme != null) @@ -53,23 +53,20 @@ The example below demonstrates how to add values programmatically using a Razor {% endhint %} ```csharp -@using Umbraco.Cms.Core.Services; -@inject IContentService Services; +@using Umbraco.Cms.Core.Services +@inject IContentService ContentService @{ - // Get access to ContentService - var contentService = Services; - // Create a variable for the GUID of the page you want to update var guid = new Guid("796a8d5c-b7bb-46d9-bc57-ab834d0d1248"); // Get the page using the GUID you've defined - var content = contentService.GetById(guid); // ID of your page + var content = ContentService.GetById(guid); // ID of your page // Set the value of the property with alias 'colorTheme' content.SetValue("colorTheme", "water"); // Save the change - contentService.Save(content); + ContentService.Save(content); } ``` @@ -78,19 +75,17 @@ Although the use of a GUID is preferable, you can also use the numeric ID to get ```csharp @{ // Get the page using it's id - var content = contentService.GetById(1234); + var content = ContentService.GetById(1234); } ``` -If Modelsbuilder is enabled you can get the alias of the desired property without using a magic string: - -{% include "../../../../.gitbook/includes/obsolete-warning-ipublishedsnapshotaccessor.md" %} +If Models Builder is enabled you can get the alias of the desired property without using a magic string: ```csharp -@using Umbraco.Cms.Core.PublishedCache; -@inject IPublishedSnapshotAccessor _publishedSnapshotAccessor; +@using Umbraco.Cms.Core.PublishedCache +@inject IPublishedContentTypeCache PublishedContentTypeCache @{ // Set the value of the property with alias 'colorTheme' - content.SetValue(Home.GetModelPropertyType(_publishedSnapshotAccessor, x => x.ColorTheme).Alias, "water"); + content.SetValue(Home.GetModelPropertyType(PublishedContentTypeCache, x => x.ColorTheme).Alias, "water"); } ``` diff --git a/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/rich-text-editor/README.md b/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/rich-text-editor/README.md index f8d115d8f4e..2cfd7507d9f 100644 --- a/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/rich-text-editor/README.md +++ b/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/rich-text-editor/README.md @@ -38,7 +38,7 @@ Extend the functionality of the Rich Text Editor with extensions. ## MVC View Example -### With Modelsbuilder +### With Models Builder ```csharp @{ @@ -49,7 +49,7 @@ Extend the functionality of the Rich Text Editor with extensions. } ``` -### Without Modelsbuilder +### Without Models Builder ```csharp @{ @@ -68,17 +68,14 @@ The example below demonstrates how to add values programmatically using a Razor {% endhint %} ```csharp -@using Umbraco.Cms.Core.Services; -@inject IContentService Services; +@using Umbraco.Cms.Core.Services +@inject IContentService ContentService @{ - // Get access to ContentService - var contentService = Services; - // Create a variable for the GUID of the page you want to update var guid = Guid.Parse("32e60db4-1283-4caa-9645-f2153f9888ef"); // Get the page using the GUID you've defined - var content = contentService.GetById(guid); // ID of your page + var content = ContentService.GetById(guid); // ID of your page // Create a variable for the desired value var htmlValue = new HtmlString("Add some text here"); @@ -87,7 +84,7 @@ The example below demonstrates how to add values programmatically using a Razor content.SetValue("richText", htmlValue); // Save the change - contentService.Save(content); + ContentService.Save(content); } ``` @@ -96,17 +93,17 @@ Although the use of a GUID is preferable, you can also use the numeric ID to get ```csharp @{ // Get the page using it's id - var content = contentService.GetById(1234); + var content = ContentService.GetById(1234); } ``` -If Modelsbuilder is enabled you can get the alias of the desired property without using a magic string. +If Models Builder is enabled you can get the alias of the desired property without using a magic string. ```csharp -@using Umbraco.Cms.Core.PublishedCache; -@inject IPublishedSnapshotAccessor _publishedSnapshotAccessor; +@using Umbraco.Cms.Core.PublishedCache +@inject IPublishedContentTypeCache PublishedContentTypeCache @{ // Set the value of the property with alias 'richText' - content.SetValue(Home.GetModelPropertyType(_publishedSnapshotAccessor, x => x.RichText).Alias, "Add some text here"); + content.SetValue(Home.GetModelPropertyType(PublishedContentTypeCache, x => x.RichText).Alias, htmlValue); } ``` diff --git a/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/slider.md b/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/slider.md index 6865dd46b97..46c977ec3f6 100644 --- a/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/slider.md +++ b/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/slider.md @@ -22,7 +22,7 @@ There are two flavors of the slider. One with a single value picker. One with a ## MVC View Example -### Without Modelsbuilder +### Without Models Builder ```csharp @if (Model.HasValue("singleValueSlider")) @@ -38,7 +38,7 @@ There are two flavors of the slider. One with a single value picker. One with a } ``` -### With Modelsbuilder +### With Models Builder ```csharp // with a range off @@ -68,40 +68,35 @@ The example below demonstrates how to add values programmatically using a Razor ### With a range off ```csharp -@using Umbraco.Cms.Core.Services; -@inject IContentService Services; +@using Umbraco.Cms.Core.Services +@inject IContentService ContentService @{ - // Get access to ContentService - var contentService = Services; - // Create a variable for the GUID of the page you want to update var guid = Guid.Parse("32e60db4-1283-4caa-9645-f2153f9888ef"); // Get the page using the GUID you've defined - var content = contentService.GetById(guid); // ID of your page + var content = ContentService.GetById(guid); // ID of your page // Set the value of the property with alias 'singleValueSlider'. content.SetValue("singleValueSlider", 10); // Save the change - contentService.Save(content); + ContentService.Save(content); } ``` ### With a range on ```csharp -@using Umbraco.Cms.Core.Services; -@inject IContentService Services; +@using Umbraco.Cms.Core.Models +@using Umbraco.Cms.Core.Services +@inject IContentService ContentService @{ - // Get access to ContentService - var contentService = Services; - // Create a variable for the GUID of the page you want to update var guid = Guid.Parse("32e60db4-1283-4caa-9645-f2153f9888ef"); // Get the page using the GUID you've defined - var content = contentService.GetById(guid); // ID of your page + var content = ContentService.GetById(guid); // ID of your page // Create a variable for the desired value of the 'multiValueSlider' property var range = new Range {Minimum = 10, Maximum = 12}; @@ -110,7 +105,7 @@ The example below demonstrates how to add values programmatically using a Razor content.SetValue("multiValueSlider", range); // Save the change - contentService.Save(content); + ContentService.Save(content); } ``` @@ -119,22 +114,20 @@ Although the use of a GUID is preferable, you can also use the numeric ID to get ```csharp @{ // Get the page using it's id - var content = contentService.GetById(1234); + var content = ContentService.GetById(1234); } ``` -If Modelsbuilder is enabled you can get the alias of the desired property without using a magic string: - -{% include "../../../../.gitbook/includes/obsolete-warning-ipublishedsnapshotaccessor.md" %} +If Models Builder is enabled you can get the alias of the desired property without using a magic string: ```csharp -@using Umbraco.Cms.Core.PublishedCache; -@inject IPublishedSnapshotAccessor _publishedSnapshotAccessor; +@using Umbraco.Cms.Core.PublishedCache +@inject IPublishedContentTypeCache PublishedContentTypeCache @{ // Set the value of the property with alias 'singleValueSlider' - content.SetValue(Home.GetModelPropertyType(_publishedSnapshotAccessor, x => x.SingleValueSlider).Alias, 10); + content.SetValue(Home.GetModelPropertyType(PublishedContentTypeCache, x => x.SingleValueSlider).Alias, 10); // Set the value of the property with alias 'multiValueSlider' - content.SetValue(Home.GetModelPropertyType(_publishedSnapshotAccessor, x => x.MultiValueSlider).Alias, new Range {Minimum = 10, Maximum = 12}); + content.SetValue(Home.GetModelPropertyType(PublishedContentTypeCache, x => x.MultiValueSlider).Alias, new Range {Minimum = 10, Maximum = 12}); } ``` diff --git a/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/tags.md b/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/tags.md index ea4daff0403..117c0ed9042 100644 --- a/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/tags.md +++ b/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/tags.md @@ -40,7 +40,7 @@ Whenever a tag has been added it will be visible in the typeahead when you start ## MVC View Example - displays a list of tags -### Multiple items - with Modelsbuilder +### Multiple items - with Models Builder ```csharp @if(Model.Tags.Any()){ @@ -52,7 +52,7 @@ Whenever a tag has been added it will be visible in the typeahead when you start } ``` -### Multiple items - without Modelsbuilder +### Multiple items - without Models Builder ```csharp @if(Model.HasValue("tags")) @@ -78,23 +78,20 @@ The example below demonstrates how to add values programmatically using a Razor ```csharp @using Umbraco.Cms.Core.Serialization @using Umbraco.Cms.Core.Services -@inject IContentService Services; -@inject IJsonSerializer Serializer; +@inject IContentService ContentService +@inject IJsonSerializer Serializer @{ - // Get access to ContentService - var contentService = Services; - // Create a variable for the GUID of the page you want to update var guid = Guid.Parse("9daf8585-6ab6-4ac2-98f0-28bf83aeea6e"); // Get the page using the GUID you've defined - var content = contentService.GetById(guid); // ID of your page + var content = ContentService.GetById(guid); // ID of your page // Set the value of the property with alias 'tags'. content.SetValue("tags", Serializer.Serialize(new[] { "News", "Umbraco", "Example", "Setting Tags", "Helper" })); // Save the change - contentService.Save(content); + ContentService.Save(content); } ``` @@ -103,20 +100,18 @@ Although the use of a GUID is preferable, you can also use the numeric ID to get ```csharp @{ // Get the page using it's id - var content = contentService.GetById(1234); + var content = ContentService.GetById(1234); } ``` -If Modelsbuilder is enabled, you can get the alias of the desired property without using a magic string: - -{% include "../../../../.gitbook/includes/obsolete-warning-ipublishedsnapshotaccessor.md" %} +If Models Builder is enabled, you can get the alias of the desired property without using a magic string: ```csharp -@using Umbraco.Cms.Core.PublishedCache; -@inject IPublishedSnapshotAccessor _publishedSnapshotAccessor; +@using Umbraco.Cms.Core.PublishedCache +@inject IPublishedContentTypeCache PublishedContentTypeCache @{ // Set the value of the property with alias 'tags' - content.SetValue(Home.GetModelPropertyType(_publishedSnapshotAccessor, x => x.Tags).Alias, Serializer.Serialize(new[] { "News", "Umbraco", "Example", "Setting Tags" })); + content.SetValue(Home.GetModelPropertyType(PublishedContentTypeCache, x => x.Tags).Alias, Serializer.Serialize(new[] { "News", "Umbraco", "Example", "Setting Tags" })); } ``` diff --git a/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/textarea.md b/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/textarea.md index e241e536a29..646f6f544e6 100644 --- a/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/textarea.md +++ b/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/textarea.md @@ -26,7 +26,7 @@ Textarea is an HTML textarea control for multiple lines of text. It can be confi ## MVC View Example -### Without Modelsbuilder +### Without Models Builder ```csharp @{ @@ -36,7 +36,7 @@ Textarea is an HTML textarea control for multiple lines of text. It can be confi } ``` -### With Modelsbuilder +### With Models Builder ```csharp @if (!Model.HasValue(Model.Description)) @@ -54,23 +54,20 @@ The example below demonstrates how to add values programmatically using a Razor {% endhint %} ```csharp -@using Umbraco.Cms.Core.Services; -@inject IContentService Services; - +@using Umbraco.Cms.Core.Services +@inject IContentService ContentService @{ - // Get access to ContentService - var contentService = Services; - // Create a variable for the GUID of your page var guid = new Guid("796a8d5c-b7bb-46d9-bc57-ab834d0d1248"); // Get the page using the GUID you've just defined - var content = contentService.GetById(guid); + var content = ContentService.GetById(guid); + // Set the value of the property with alias 'description' content.SetValue("description", "This is some text for the text area!"); // Save the change - contentService.Save(content); + ContentService.Save(content); } ``` @@ -79,20 +76,18 @@ Although the use of a GUID is preferable, you can also use the numeric ID to get ```csharp @{ // Get the page using it's id - var content = contentService.GetById(1234); + var content = ContentService.GetById(1234); } ``` -If Modelsbuilder is enabled you can get the alias of the desired property without using a magic string: - -{% include "../../../../.gitbook/includes/obsolete-warning-ipublishedsnapshotaccessor.md" %} +If Models Builder is enabled you can get the alias of the desired property without using a magic string: ```csharp -@using Umbraco.Cms.Core.PublishedCache; -@inject IPublishedSnapshotAccessor _publishedSnapshotAccessor; +@using Umbraco.Cms.Core.PublishedCache +@inject IPublishedContentTypeCache PublishedContentTypeCache @{ // Set the value of the property with alias 'description' - content.SetValue(Home.GetModelPropertyType(_publishedSnapshotAccessor, x => x.Description).Alias, "This is some text for the text area!"); + content.SetValue(Home.GetModelPropertyType(PublishedContentTypeCache, x => x.Description).Alias, "This is some text for the text area!"); } ``` diff --git a/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/textbox.md b/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/textbox.md index 84cd4b41978..56e56e92d11 100644 --- a/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/textbox.md +++ b/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/textbox.md @@ -28,7 +28,7 @@ Textbox is an HTML input control for text. It can be configured to have a fixed ## MVC View Example -### Without Modelsbuilder +### Without Models Builder ```csharp @{ @@ -40,7 +40,7 @@ Textbox is an HTML input control for text. It can be configured to have a fixed } ``` -### With Modelsbuilder +### With Models Builder ```csharp @{ @@ -62,23 +62,20 @@ The example below demonstrates how to add values programmatically using a Razor {% endhint %} ```csharp -@using Umbraco.Cms.Core.Services; -@inject IContentService Services; +@using Umbraco.Cms.Core.Services +@inject IContentService ContentService @{ - // Get access to ContentService - var contentService = Services; - // Create a variable for the GUID of the page you want to update var guid = new Guid("32e60db4-1283-4caa-9645-f2153f9888ef"); // Get the page using the GUID you've defined - var content = contentService.GetById(guid); // ID of your page + var content = ContentService.GetById(guid); // ID of your page // Set the value of the property with alias 'pageTitle' content.SetValue("pageTitle", "Umbraco Demo"); // Save the change - contentService.Save(content); + ContentService.Save(content); } ``` @@ -87,20 +84,17 @@ Although the use of a GUID is preferable, you can also use the numeric ID to get ```csharp @{ // Get the page using it's id - var content = contentService.GetById(1234); + var content = ContentService.GetById(1234); } ``` -If Modelsbuilder is enabled you can get the alias of the desired property without using a magic string: - -{% include "../../../../.gitbook/includes/obsolete-warning-ipublishedsnapshotaccessor.md" %} +If Models Builder is enabled you can get the alias of the desired property without using a magic string: ```csharp -@using Umbraco.Cms.Core.PublishedCache; -@inject IPublishedSnapshotAccessor _publishedSnapshotAccessor; +@using Umbraco.Cms.Core.PublishedCache +@inject IPublishedContentTypeCache PublishedContentTypeCache @{ - // Set the value of the property with alias 'pageTitle' - content.SetValue(Home.GetModelPropertyType(_publishedSnapshotAccessor, x => x.PageTitle).Alias, "Umbraco Demo"); + content.SetValue(Home.GetModelPropertyType(PublishedContentTypeCache, x => x.PageTitle).Alias, "Umbraco Demo"); } ``` diff --git a/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/true-false.md b/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/true-false.md index 0eb89c9a21e..db185c002a8 100644 --- a/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/true-false.md +++ b/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/true-false.md @@ -22,7 +22,7 @@ It is also possible to define a label, that will be displayed next to the checkb ## MVC View Example -### Without Modelsbuilder +### Without Models Builder ```csharp @{ @@ -33,7 +33,7 @@ It is also possible to define a label, that will be displayed next to the checkb } ``` -### With Modelsbuilder +### With Models Builder ```csharp @{ @@ -53,23 +53,20 @@ The example below demonstrates how to add values programmatically using a Razor {% endhint %} ```csharp -@using Umbraco.Cms.Core.Services; -@inject IContentService Services; +@using Umbraco.Cms.Core.Services +@inject IContentService ContentService @{ - // Get access to ContentService - var contentService = Services; - // Create a variable for the GUID of the page you want to update var guid = new Guid("796a8d5c-b7bb-46d9-bc57-ab834d0d1248"); // Get the page using the GUID you've defined - var content = contentService.GetById(guid); // ID of your page + var content = ContentService.GetById(guid); // ID of your page // Set the value of the property with alias 'myCheckBox' content.SetValue("myCheckBox", true); // Save the change - contentService.Save(content); + ContentService.Save(content); } ``` @@ -78,20 +75,17 @@ Although the use of a GUID is preferable, you can also use the numeric ID to get ```csharp @{ // Get the page using it's id - var content = contentService.GetById(1234); + var content = ContentService.GetById(1234); } ``` -If Modelsbuilder is enabled you can get the alias of the desired property without using a magic string: - -{% include "../../../../.gitbook/includes/obsolete-warning-ipublishedsnapshotaccessor.md" %} +If Models Builder is enabled you can get the alias of the desired property without using a magic string: ```csharp -@using Umbraco.Cms.Core.PublishedCache; -@inject IPublishedSnapshotAccessor _publishedSnapshotAccessor; +@using Umbraco.Cms.Core.PublishedCache +@inject IPublishedContentTypeCache PublishedContentTypeCache @{ // Set the value of the property with alias 'myCheckBox' - content.SetValue(Home.GetModelPropertyType(_publishedSnapshotAccessor,x => x.MyCheckBox).Alias, true); - + content.SetValue(Home.GetModelPropertyType(PublishedContentTypeCache, x => x.MyCheckBox).Alias, true); } ``` diff --git a/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/user-picker.md b/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/user-picker.md index 0c8320c1d93..4a43c573393 100644 --- a/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/user-picker.md +++ b/16/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/user-picker.md @@ -22,7 +22,7 @@ The user picker opens a panel to pick a specific user from the Users section. Th Getting the Value of the property will return the user ID - properties of the User can be accessed by referencing UserService. {% endhint %} -### Without Modelsbuilder +### Without Models Builder ```csharp @using Umbraco.Cms.Core.Services; @@ -40,7 +40,7 @@ Getting the Value of the property will return the user ID - properties of the Us } ``` -### With Modelsbuilder +### With Models Builder ```csharp @using Umbraco.Cms.Core.Services; @@ -67,22 +67,20 @@ The example below demonstrates how to add values programmatically using a Razor {% endhint %} ```csharp -@inject IContentService Services; +@using Umbraco.Cms.Core.Services +@inject IContentService ContentService @{ - // Get access to ContentService - var contentService = Services; - // Create a variable for the GUID of the page you want to update var guid = new Guid("796a8d5c-b7bb-46d9-bc57-ab834d0d1248"); // Get the page using the GUID you've defined - var content = contentService.GetById(guid); // ID of your page + var content = ContentService.GetById(guid); // ID of your page // Set the value of the property with alias 'userPicker'. The value is the specific ID of the user content.SetValue("userPicker", -1); // Save the change - contentService.Save(content); + ContentService.Save(content); } ``` @@ -91,18 +89,17 @@ Although the use of a GUID is preferable, you can also use the numeric ID to get ```csharp @{ // Get the page using it's id - var content = contentService.GetById(1234); + var content = ContentService.GetById(1234); } ``` -If Modelsbuilder is enabled you can get the alias of the desired property without using a magic string: - -{% include "../../../../.gitbook/includes/obsolete-warning-ipublishedsnapshotaccessor.md" %} +If Models Builder is enabled you can get the alias of the desired property without using a magic string: ```csharp -@inject IPublishedSnapshotAccessor _publishedSnapshotAccessor; +@using Umbraco.Cms.Core.PublishedCache +@inject IPublishedContentTypeCache PublishedContentTypeCache @{ // Set the value of the property with alias 'userPicker' - content.SetValue(Home.GetModelPropertyType(_publishedSnapshotAccessor, x => x.UserPicker).Alias, "Umbraco Demo"); + content.SetValue(Home.GetModelPropertyType(PublishedContentTypeCache, x => x.UserPicker).Alias, -1); } ``` diff --git a/16/umbraco-cms/reference/templating/modelsbuilder/introduction.md b/16/umbraco-cms/reference/templating/modelsbuilder/introduction.md index 87c7d4a7ab7..843d51c5b29 100644 --- a/16/umbraco-cms/reference/templating/modelsbuilder/introduction.md +++ b/16/umbraco-cms/reference/templating/modelsbuilder/introduction.md @@ -10,14 +10,12 @@ Models can be used anywhere that content is retrieved from the content cache, i. For each content, media and member type in the Umbraco setup, the generator creates a `*.generated.cs` file, corresponding to the type. For instance, a document type with a textstring property named Title, and a rich text editor named BodyText will look like this: -{% include "../../../.gitbook/includes/obsolete-warning-snapshot-publishedcache.md" %} - ```csharp //------------------------------------------------------------------------------ // // This code was generated by a tool. // -// Umbraco.ModelsBuilder.Embedded v9.0.0-beta003+b07f6519e7a1c890b534502982612ce6b3fea293 +// Umbraco.ModelsBuilder.Embedded v15.0.0 // // Changes to this file will be lost if the code is regenerated. // @@ -39,16 +37,18 @@ public partial class NewsItem : PublishedContentModel { // helpers #pragma warning disable 0109 // new is redundant - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "9.0.0-beta003+b07f6519e7a1c890b534502982612ce6b3fea293")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "15.0.0")] public new const string ModelTypeAlias = "newsItem"; - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "9.0.0-beta003+b07f6519e7a1c890b534502982612ce6b3fea293")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "15.0.0")] public new const PublishedItemType ModelItemType = PublishedItemType.Content; - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "9.0.0-beta003+b07f6519e7a1c890b534502982612ce6b3fea293")] - public new static IPublishedContentType GetModelContentType(IPublishedSnapshotAccessor publishedSnapshotAccessor) - => PublishedModelUtility.GetModelContentType(publishedSnapshotAccessor, ModelItemType, ModelTypeAlias); - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "9.0.0-beta003+b07f6519e7a1c890b534502982612ce6b3fea293")] - public static IPublishedPropertyType GetModelPropertyType(IPublishedSnapshotAccessor publishedSnapshotAccessor, Expression> selector) - => PublishedModelUtility.GetModelPropertyType(GetModelContentType(publishedSnapshotAccessor), selector); + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "15.0.0")] + [return: global::System.Diagnostics.CodeAnalysis.MaybeNull] + public new static IPublishedContentType GetModelContentType(IPublishedContentTypeCache contentTypeCache) + => PublishedModelUtility.GetModelContentType(contentTypeCache, ModelItemType, ModelTypeAlias); + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "15.0.0")] + [return: global::System.Diagnostics.CodeAnalysis.MaybeNull] + public static IPublishedPropertyType GetModelPropertyType(IPublishedContentTypeCache contentTypeCache, Expression> selector) + => PublishedModelUtility.GetModelPropertyType(GetModelContentType(contentTypeCache), selector); #pragma warning restore 0109 private IPublishedValueFallback _publishedValueFallback; @@ -65,14 +65,16 @@ public partial class NewsItem : PublishedContentModel /// /// BodyText /// - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "9.0.0-beta003+b07f6519e7a1c890b534502982612ce6b3fea293")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "15.0.0")] + [global::System.Diagnostics.CodeAnalysis.MaybeNull] [ImplementPropertyType("bodyText")] public virtual global::Umbraco.Cms.Core.Strings.IHtmlEncodedString BodyText => this.Value(_publishedValueFallback, "bodyText"); /// /// Title /// - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "9.0.0-beta003+b07f6519e7a1c890b534502982612ce6b3fea293")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "15.0.0")] + [global::System.Diagnostics.CodeAnalysis.MaybeNull] [ImplementPropertyType("title")] public virtual string Title => this.Value(_publishedValueFallback, "title"); } diff --git a/16/umbraco-cms/reference/templating/modelsbuilder/understand-and-extend.md b/16/umbraco-cms/reference/templating/modelsbuilder/understand-and-extend.md index 018e2d6f5d1..5ecccd743c2 100644 --- a/16/umbraco-cms/reference/templating/modelsbuilder/understand-and-extend.md +++ b/16/umbraco-cms/reference/templating/modelsbuilder/understand-and-extend.md @@ -11,8 +11,6 @@ Umbraco’s Models Builder automatically generates strongly typed models for con Models Builder generates each content type as a partial class. For example, a content type named `TextPage` results in a `TextPage.generated.cs` file with a structure like this: -{% include "../../../.gitbook/includes/obsolete-warning-ipublishedsnapshotaccessor.md" %} - ```csharp /// TextPage [PublishedModel("textPage")] @@ -23,11 +21,11 @@ public partial class TextPage : PublishedContentModel public new const PublishedItemType ModelItemType = PublishedItemType.Content; - public new static IPublishedContentType GetModelContentType(IPublishedSnapshotAccessor publishedSnapshotAccessor) - => PublishedModelUtility.GetModelContentType(publishedSnapshotAccessor, ModelItemType, ModelTypeAlias); + public new static IPublishedContentType GetModelContentType(IPublishedContentTypeCache contentTypeCache) + => PublishedModelUtility.GetModelContentType(contentTypeCache, ModelItemType, ModelTypeAlias); - public static IPublishedPropertyType GetModelPropertyType(IPublishedSnapshotAccessor publishedSnapshotAccessor, Expression> selector) - => PublishedModelUtility.GetModelPropertyType(GetModelContentType(publishedSnapshotAccessor), selector); + public static IPublishedPropertyType GetModelPropertyType(IPublishedContentTypeCache contentTypeCache, Expression> selector) + => PublishedModelUtility.GetModelPropertyType(GetModelContentType(contentTypeCache), selector); private IPublishedValueFallback _publishedValueFallback;