Constellation.Foundation.ModelMapping
10.3.0.23496
dotnet add package Constellation.Foundation.ModelMapping --version 10.3.0.23496
NuGet\Install-Package Constellation.Foundation.ModelMapping -Version 10.3.0.23496
<PackageReference Include="Constellation.Foundation.ModelMapping" Version="10.3.0.23496" />
paket add Constellation.Foundation.ModelMapping --version 10.3.0.23496
#r "nuget: Constellation.Foundation.ModelMapping, 10.3.0.23496"
// Install Constellation.Foundation.ModelMapping as a Cake Addin #addin nuget:?package=Constellation.Foundation.ModelMapping&version=10.3.0.23496 // Install Constellation.Foundation.ModelMapping as a Cake Tool #tool nuget:?package=Constellation.Foundation.ModelMapping&version=10.3.0.23496
Requires Sitecore 10.3
Requires .NET 4.8
Constellation is a collection of utilities for .NET CMS implementers.
The Foundation.ModelMapping library is inspired by AutoMapper and is designed to provide a quick, non-ORM method of mapping Sitecore Items to ViewModels. String properties on your ViewModel will be mapped to FieldRendered values from fields with the same names. Integer and DateTime property types can also be handled automatically, although you will not get page editor support for these types. There are a number of Attributes that you can assign to your ViewModel's properties to change the behavior of the Mapper.
Usage:
var modelMapper = (IModelMapper)ServiceLocator.ServiceProvider.GetService(typeof(IModelMapper)); // Dependency Injection of an IModelMapper is supported
TModel viewModel = modelMapper.MapItemToNew<TModel>(sourceItem);
Or: TModel viewmodel = item.MapToNew<TModel>();
Or: modelMapper.MapTo(item, model);
When using Item or ItemList extensions for mapping, the context IModelMapper is requested from the ServiceLocator, so any moc objects you use for testing are supported with these extension methods.
Constraints:
- Your ViewModel must have a public, parameterless constructor.
- Only Writable, Public Instance properties will be mapped.
- Within Sitecore, your field names can be human-legible. ModelMapper will attempt to convert the field name to a valid Property name. Simpler names work best.
You can use the Field's Display Name for better human legibility and keep the Field's actual name closer to a legit C# entity name.
- ViewModel properties can be:
- - Strings
- - HtmlStrings (recommended for RichText and FieldRenderer)
- - Integers
- - Decimals
- - DateTimes
- - Other ViewModels (recommended for DropLink, DropTree)
- - ICollection Generics of other ViewModels (recommended for Multilist, Treelist)
- - ModelMapping.Model.ImageModel (for Image Fields, gives access to all field properties and permits generating different kinds of image URLs on the View.)
- - ModelMapping.Model.GeneralLinkModel (for General Link fields, gives access to all field properties through a single object.)
- - Random Plain Old Classes as long as they are Where T: class, new()
The following Model properties are mapped to Item properties rather than Item fields:
- ID - Maps to the Item.ID - Make sure you use Sitecore.Data.ID as the property type.
- Name - Maps to the Item.Name
- DisplayName - Maps to Item.DisplayName
- Url - Should be a string, not a Uri. Causes the current context LinkManager to generate a Url for the Item.
- Parent - Maps to the ViewModel you provide based on the Item.Parent.
Support for XML Field Attributes
- ImageField.Alt - use Model.FieldNameAlt
- ImageField.Height - use Model.FieldNameHeight
- GeneralLink.Target - use Model.FieldNameTarget
- etc.
Support for LinkField.TargetItem - use Model.FieldNameTargetItem and supply a class with public properties and a parameterless constructor.
Support for MultilistField.GetItems - use Model.FieldName and supply a generic ICollection<T> where "T" is new() and has properties you can map.
Extensible! See the Constellation.Foundation.ModelMapping.config file to change the way Fields are processed.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net48 is compatible. net481 was computed. |
-
- Constellation.Foundation.Data (>= 10.3.0.23123)
NuGet packages (6)
Showing the top 5 NuGet packages that depend on Constellation.Foundation.ModelMapping:
Package | Downloads |
---|---|
Constellation.Feature.Navigation
Requires Sitecore 10.3 Requires .NET Framework 4.8 Constellation is a collection of utilities for .NET CMS implementers. The Feature.Navigation library addresses the three most common forms of Navigation on Sitecore sites: Declared (static) Navigation: (explicitly defined, may differ from the shape of the content tree) - DeclaredNavigationRepository.GetNavigation - Accepts a Navigation Menu item and assembles a full tree-like ViewModel for immediate processing in your View. If you need context highlighting in your navigation, be sure to pass in the Context Item as well. When using NavigationLink objects, there are usually several opportunities to supply the text of a given link. NavigationLink.GetBestLinkText() evaluates all of them and attempts to supply the best fit. The strategy is based on overriding the concept of "name". Here are the rules: - If Use This Display Name is checked on the NavigationLink item, it wins. - If the Link.Text is supplied by the user, it wins. - If the Link.TargetItem exists and inherits from Page Navigation Title, and the field value is not null, it wins. - If the Link.TargetItem exists its DisplayName is used. - Assuming all other things are not true, use the NavigationLink's DisplayName. Note that in this condition if you intended to point to a Sitecore Item, you have a bad link. Branch (Context) Navigation: (implicitly defined. It follows the shape of the Content Tree) - BranchNavigationRepository.GetNavigation - Accepts the request Context Item (should be a Page) and generates a tree of BranchNodes representing the nearest LandingPage, its children, as well as the descendants of any children that are Ancestors of the Context Item. (will also create Children for the Context Item node in the tree). Use this to produce the expanded navigation seen on many sites with deep content. Breadcrumbs: (implicitly defined. It walks up the Content Tree to get the path) - BreadcrumbNavigationRepository.GetNavigation - Accepts the request Context Item and Context SiteInfo. Generates an array of Breadcrumb models you can enumerate on your View. The breadcrumbs will start on your Site's StartItem and end with the supplied Context Item, which will be marked IsContextItem so you can change your rendering behavior. Uses the Item.Axes.GetAncestors() method to generate the list of breadcrumbs. The included package must be installed to use this library. This should happen automatically after you build and deploy your project. |
|
Constellation.Feature.PageAnalyticsScripts
Requires Sitecore 10.3 Requires .NET Framework 4.8 Constellation is a collection of utilities for .NET CMS implementers. The Feature.PageAnalyticsScripts namespace contains controllers that will render 3rd party analytics and reporting scripts to the page. To get the controllers and supporting Data Templates, the included Sitecore package must be installed This should happen automatically when you build and deploy your project. After installation, some configuration within Sitecore is required. 1. You need to select a location for Page Analytics Scripts Items. 2. For each of the Controller Renderings provided in the package, you need to set the Datasource Folder field to the above location. 3. It is recommended that you create placeholders for the Html Header tag as well as the top and bottom of the Body tags. You can then assign the provided Controller Renderings to those locations in the Standard Values of your most basic Page Items. This module isolates the analytics script kit from actual pages, so you may share scripts on multiple pages (typically every page on a site references the same datasource). You can also "stack" scripts by adding multiple instances of the controller renderings with different datasources. This module does not directly support page/experience editor because: 1. Scripts are invisible 2. Their location in the HTML document may make it difficult to provide access to the rendering. Because maintaining these scripts requires knowledge of Javascript and Marketing Technology, it is recommended that only users familiar with the Presentation Details dialog maintain these objects. |
|
Constellation.Feature.PageTagging
Requires Sitecore 10.3 Requires .NET Framework 4.8 Constellation is a collection of utilities for .NET CMS implementers. The Feature.PageTagging namespace contains controllers that will render the following meta tags when installed on page: - name=keywords - name=description - name=publisher - name=author - name=robots - name=twitter:card - name=twitter:creator - name=twitter:site - property=og:url - property=og:title - property=og:description - property=og:image These tags provide good SEO support as well as good support for Facebook and Twitter. The Sitecore Package in /Installation-Packages must be installed to take advantage of this library. The package includes: - Data Templates for the fields required to support these tags. Your pages should inherit from these to take advantage of this library. - List items where fields have a limited choice of values. - Rendering definitions. The package should self-install when you build and deploy your project. To use, in your Layout, at the appropriate location enter the following: @Html.Sitecore().Rendering("/sitecore/layout/renderings/feature/constellation/page tagging/page metadata") @Html.Sitecore().Rendering("/sitecore/layout/renderings/feature/constellation/page tagging/page search engine directives") @Html.Sitecore().Rendering("/sitecore/layout/renderings/feature/constellation/page tagging/page social metadata") |
|
Constellation.Feature.Redirects
Requires Sitecore 10.3 Requires .NET Framework 4.8 Constellation is a collection of utilities for .NET CMS implementers. The Feature.Redirects namespace contains two discrete functional components: Page Redirects: Items that are meant to be interspersed with Page type Items in the content tree so that dynamically generated navigation will list these Items as if they were part of that tree branch, although the actual target is elsewhere, or an entirely different site altogether. Marketing Redirects: Items that represent "short, catchy" URLs that then redirect deeper into the site. Also a way to teach search engines about URLs that have been permanently relocated. Marketing Redirects are managed through a discrete "application" in the Sitecore desktop. Exporting and importing redirect lists is supported. All redirects are tested for validity before they are allowed to be imported. The porting and development of this library has been kindly supported by Verndale (verndale.com) |
|
Constellation.Foundation.Mvc.Patterns
Requires Sitecore 10.3 Requires .NET Framework 4.8 Constellation is a collection of utilities for .NET CMS implementers. The Foundation.Mvc.Patterns library is an opinionated library that provides some base Controller and Repository classes for jumpstarting a Sitecore project. The purpose is to get developers to better separate data access logic from controllers and also to hide some uninteresting concerns. Repositories: Classes which accept a context to specify the conditions for accessing data in Sitecore along with facts for use in the query. The Repository is responsible for getting the results of a query, any caching, and any transformation into ViewModel output. Base Repositories: Repository - Just the basics of setting up the relationship between the repository and the controller. CachingRepository - Adds caching of the repository's output to the mix. SingleItemRepository - Includes both of above and is centered around queries that will retrieve a single Item. ItemListRepository - Includes the first two and is centered around queries taht will retrieve multiple Items. Controllers: Classes which are responsible for handling the transition from Sitecore to the View, including setting up a Repository Context, and getting the results from the Repository for sending to the View. Base Controllers: DatasourceRenderingController - Use when a Rendering has a Datasource Item and that Item is what's being rendered. ItemListController - Use when a Rendering will present a number of Items that have to be looked up in some fashion. On Sitecore startup, this package will scan all assemblies for IController and IRepository implementations and automatically add them to Dependency Injection. This feature can be disabled/changed via the config file for this package. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
10.3.0.23496 | 5,998 | 6/16/2023 |
10.2.7.23399 | 3,371 | 2/7/2023 |
10.2.6.14185 | 2,276 | 1/31/2023 |
10.2.5.29046 | 2,194 | 1/30/2023 |
10.2.4.23594 | 14,758 | 3/7/2022 |
10.2.3.22209 | 2,383 | 2/11/2022 |
10.2.2.20071 | 2,474 | 2/11/2022 |
10.2.1.25406 | 2,526 | 2/2/2022 |
10.2.0.30381 | 15,444 | 11/12/2021 |
10.1.4.22077 | 3,399 | 2/11/2022 |
10.1.3.19919 | 2,316 | 2/11/2022 |
10.1.2.25254 | 2,432 | 2/2/2022 |
10.1.1.25245 | 2,636 | 10/25/2021 |
10.1.0.29258 | 10,324 | 3/4/2021 |
10.0.8.16246 | 4,777 | 1/6/2021 |
10.0.7.20073 | 3,552 | 12/28/2020 |
10.0.6.24075 | 4,764 | 11/20/2020 |
10.0.5.32533 | 2,783 | 11/5/2020 |
10.0.4.24372 | 2,675 | 9/25/2020 |
10.0.3.22928 | 2,719 | 9/1/2020 |
10.0.2.24237 | 2,614 | 8/20/2020 |
10.0.1.23906 | 6,629 | 8/5/2020 |
10.0.0.23188 | 4,874 | 8/4/2020 |
9.3.2.16363 | 2,745 | 1/6/2021 |
9.3.1.26142 | 2,751 | 9/25/2020 |
9.3.0.29450 | 7,914 | 6/4/2020 |
9.1.15.16445 | 2,691 | 1/6/2021 |
9.1.14.26346 | 2,624 | 9/25/2020 |
9.1.13.23109 | 2,615 | 9/1/2020 |
9.1.12.19097 | 2,726 | 8/20/2020 |
9.1.11.16238 | 3,917 | 2/28/2020 |
9.1.10.19264 | 7,034 | 12/20/2019 |
9.1.9.30419 | 2,825 | 12/19/2019 |
9.1.8.25631 | 5,321 | 12/9/2019 |
9.1.7.27091 | 2,791 | 12/6/2019 |
9.1.6.15984 | 7,095 | 6/4/2019 |
9.1.5.27908 | 3,768 | 6/3/2019 |
9.1.4.28433 | 5,685 | 5/28/2019 |
9.1.3.23444 | 5,533 | 4/11/2019 |
9.1.2.24353 | 5,325 | 3/6/2019 |
9.1.1.23876 | 5,861 | 1/18/2019 |
9.1.0.16301 | 7,701 | 12/7/2018 |
9.0.33.27934 | 8,053 | 10/25/2018 |
9.0.32.25356 | 5,426 | 10/20/2018 |
9.0.31.30043 | 2,956 | 10/19/2018 |
9.0.30.20651 | 6,645 | 10/18/2018 |
9.0.30.16759 | 4,564 | 10/18/2018 |
9.0.29.16036 | 3,360 | 10/18/2018 |
9.0.28.29823 | 2,996 | 10/17/2018 |
9.0.27.22655 | 7,574 | 10/16/2018 |
9.0.26.31767 | 2,949 | 10/14/2018 |
9.0.25.30713 | 2,934 | 10/14/2018 |
9.0.24.28294 | 2,963 | 10/14/2018 |
9.0.23.20463 | 6,134 | 7/23/2018 |
9.0.22.29260 | 3,128 | 7/3/2018 |
9.0.21.16778 | 5,129 | 5/31/2018 |
9.0.20.26586 | 4,608 | 5/25/2018 |
9.0.19.21403 | 3,842 | 5/18/2018 |
9.0.18.17384 | 3,899 | 2/20/2018 |
9.0.17.20638 | 3,131 | 2/12/2018 |
9.0.17.17874 | 4,172 | 2/12/2018 |
9.0.16.23947 | 4,089 | 1/12/2018 |
9.0.15.30124 | 3,922 | 1/11/2018 |
9.0.14.22754 | 3,890 | 1/11/2018 |
9.0.13.26948 | 3,122 | 1/10/2018 |
9.0.13.20538 | 4,179 | 1/10/2018 |
9.0.12.19321 | 3,294 | 1/10/2018 |
9.0.11.23261 | 4,577 | 1/8/2018 |
9.0.10.18305 | 5,440 | 12/8/2017 |
9.0.9.27813 | 3,883 | 12/6/2017 |
9.0.9.24928 | 3,850 | 12/6/2017 |
9.0.9.19108 | 3,856 | 12/6/2017 |
9.0.8.28378 | 3,731 | 12/5/2017 |
9.0.7.25385 | 3,653 | 12/5/2017 |
9.0.6.28191 | 3,668 | 12/4/2017 |
9.0.5.22638 | 4,737 | 12/3/2017 |
9.0.4.21382 | 3,732 | 12/3/2017 |
9.0.4.21146 | 3,125 | 12/3/2017 |
9.0.3.27874 | 3,121 | 12/1/2017 |
9.0.1.27414 | 3,036 | 11/30/2017 |
9.0.1.18427 | 3,071 | 11/30/2017 |
9.0.0.35644 | 3,147 | 11/29/2017 |
9.0.0.30418 | 3,180 | 11/29/2017 |
9.0.0.27220 | 3,140 | 11/29/2017 |
8.1.3.19984 | 15,182 | 5/18/2020 |
8.1.3.19261 | 2,779 | 5/18/2020 |
Updated Sitecore version to 10.3.