Sitecore has five list field types that Glass Mapper maps: Checklist, Multilist, Multilist with Search, Treelist, and TreelistEx. Out of the box, Glass Mapper supports mapping these field types to two .NET collection types: IEnumerable<T> and IList<T>. In this post I’ll cover how to use Glass Mapper to map your code models to these field types.
Blogs from this Author
Glass Mapper – Map Sitecore Rules Fields
Glass Mapper handles mapping of almost all Sitecore field types to your models, but I discovered one Sitecore field type that Glass Mapper can handle that isn’t well documented: the Rules field type. If you haven’t worked with the Sitecore Rules field type before, Jeff Darchuk has an excellent blog post about the Sitecore rules API that […]
Sitecore PowerShell – Change Item Template and Retain Field Value
I was recently tasked with changing the template of some items in one of our client’s Sitecore instances. Both the SourceTemplate and TargetTemplate had an image field, and part of the task was to transfer the value of the MainImage field of SourceTemplate to the PrimaryImage field of TargetTemplate. The templates looked similar to the following: SourceTemplate MainImage – […]
Sitecore – Remove Port 443 from Sitecore-Generated HTTPS URLs
After we enabled HTTPS on one of our clients’ sites in their pre-prod environment, Sitecore started to add :443 to all URLs, which was undesirable from an SEO perspective. I found this question on Stack Overflow about the issue, and I tried the suggestions of setting scheme=”https” and port=”443″ in the site definition, hoping that Sitecore’s built-in LinkProvider would recognize :443 to be redundant in the URLs, […]
Sitecore MVC – Globally-Templated Attribute Routes
I’ve worked on a few projects that make use of John West‘s technique to create AJAX services for your Sitecore components, as outlined in his blog post here. In a fresh Sitecore project, the action methods on your controllers are accessible from Sitecore only–you can’t access them by navigating to http://{{yoursiteurl}}/{controller}/{action} like you would in a […]
Sitecore – Extend Treelist to Support Relative Datasource Paths
The Datasource Location field on renderings in Sitecore supports a nice feature that I’ve taken for granted–relative paths. For example, if you want content authors to put the data items for a particular rendering under the item that the rendering is on in the content tree, you can specify the Datasource Location as ./. The Treelist field has a […]
Sitecore WFFM – View Compilation Error after Upgrade to 8.1
After fixing the controller not found exception following our client’s recent upgrade to Web Forms for Marketers 8.1, all of our forms continued to throw an exception on load: Compilation Error. CS0104: ‘Constants’ is an ambiguous reference between ‘Sitecore.Forms.Mvc.Constants’ and ‘SitecoreDemo.Constants’. Web Forms for Marketers installs several views and editor templates into your Sitecore installation at […]
Sitecore WFFM – Controller Not Found after Upgrade to 8.1
We recently upgraded one of our clients from Sitecore 8.0 to Sitecore 8.1 and had to upgrade to Web Forms for Marketers 8.1 rev. 160304 as part of the upgrade. After upgrading WFFM, all of our forms started to throw the following exception: The controller for path ‘{{form path}}’ could not be found. The project has a custom Controller Factory that uses […]
Sitecore MVC – Independent Experience Editor Views
I find that many of the components I develop in Sitecore need custom markup in the Experience Editor that shouldn’t be present on the live site. Although it’s possible to add this custom markup into my components’ views with @if (Sitecore.Context.PageMode.IsExperienceEditor), I prefer to keep branching logic out of my views as much as possible. Fortunately […]
Sitecore – Null Value Exception When Opening Explore Mode
Sitecore 8 introduced a new Explore Mode option to the Experience Editor that allows content authors to test their digital marketing strategy by simulating visits to their site as different users. One feature that has been particularly useful for me is the ability to simulate different IP addresses to test GeoIP integration in components I’m […]
Sitecore – Launchpad Exception after Removing Broken Links
A couple of days ago I accidentally removed broken links in the Core database of a new Sitecore instance using the Remove Broken Links tool at http://{your-sitecore-url}/sitecore/admin/RemoveBrokenLinks.aspx. The next time I logged into Sitecore, I got the following exception: After some digging around I found that the Remove Broken Links tool erroneously deleted the Model property of the ExperienceAnalyticsLineChart […]
Hedgehog TDS – Field Content Does Not Match Content-Length
Hedgehog’s Team Development for Sitecore has made Sitecore development with teams a dream. Gone are the days of passing around packages and keeping track of your Sitecore changes in notepad for each commit. As great as TDS has been, I’ve run into an issue on a couple of projects recently when using TDS with Git that […]