timeverts
09/10/2024, 2:31 AMUmbraco.Cms.Web.Common.PublishedModels
namespace?
I read a post from #byteeditor on creating starter kits and they say the class library should not contain any references at all to Models Builder models (https://byteeditor.net/blog/how-to-create-a-website-starter-kit-for-umbraco/#:~:text=The%20code%20in,used%20in%20views.). But I see in some other starter kits (e.g. Clean by @CodeSharePaul and Atomic Starter Kit by @Rosen Petrov ) that models builder models are referenced quite commonly in the class library associated with their starter kits.
I completely understand that if a consumer using my starter kit has defined a custom models builder namespace, my starter kit might not work/break on their website. But are there any other reasons why I should avoid using models builder models in the class library?Richard Soeteman
09/10/2024, 7:09 AMCodeSharePaul
09/10/2024, 7:20 AMCodeSharePaul
09/10/2024, 7:21 AMtimeverts
09/10/2024, 7:31 AMtimeverts
09/10/2024, 7:32 AMUmbraco.Cms.Core.Models.PublishedContent
rather than Umbraco.Cms.Web.Common.PublishedModels
. SorryCodeSharePaul
09/10/2024, 7:35 AMtimeverts
09/10/2024, 7:36 AMtimeverts
09/10/2024, 7:37 AMusing Umbraco.Cms.Web.Common.PublishedModels;
using Umbraco.Cms.Core.Models;
namespace MyPackage.Web.ViewModels;
public class HeaderViewModel
{
/// <summary>
/// The logo appearing within the header.
/// </summary>
/// <remarks>This will be an Umbraco media type of either <see cref="Image"/> or <see cref="UmbracoMediaVectorGraphics"/>.</remarks>
public MediaWithCrops? Logo { get; set; }
/// <summary>
/// The items for the primary navigation within the header.
/// </summary>
public IEnumerable<WebsiteNavigationItem> PrimaryNavigationItems { get; set; } =
Enumerable.Empty<WebsiteNavigationItem>();
}
But I guess I shouldn't really put that into the class library associated with my starter kit then?timeverts
09/10/2024, 7:38 AMWebsiteNavigationItem
is a published model.CodeSharePaul
09/10/2024, 7:39 AMtimeverts
09/10/2024, 7:41 AMtimeverts
09/10/2024, 7:42 AMBackgroundImage
or Categories
properties, when they use them in the view would they typecast them to the proper models builder type, so they can get the proper object properties?CodeSharePaul
09/10/2024, 7:43 AMCodeSharePaul
09/10/2024, 7:44 AMtimeverts
09/10/2024, 7:44 AMtimeverts
09/10/2024, 7:44 AMtimeverts
09/10/2024, 7:50 AMMike Chambers
09/10/2024, 8:42 AMusing Umbraco.Cms.Web.Common.PublishedModels;
out of views and into the _ViewImports.cshtml
then whatever modelsbuilder namespace is required by the end user can be used?timeverts
09/10/2024, 8:46 AM_ViewImports.cshtml
would have to be documented as a prerequisite for installation of the starter kit, because I don't believe it's in that file by default.Mike Chambers
09/10/2024, 8:50 AMtimeverts
09/10/2024, 8:53 AMMike Chambers
09/10/2024, 8:55 AMMike Chambers
09/10/2024, 8:55 AM