Oct 5, 2011
  5082
(4 votes)

ElencySolutions.MultipleProperty v1.2 Released

The ElencySolutions.MultipleProperty assembly provides a developer with the ability to easily create custom properties that are made up of other property types.  It allows the developer to create properties that are essentially lists of other property types.  This can be done by creating entity classes and decorating them with various MultipleProperty class level and property level attributes.

The properties offer features as drag and drop sorting, the ability to programmatically set property settings for entity properties, property copying, laying out properties within different tabs and various other features.

For more information please refer to previous blog posts that are linked to from here.  Very useful documentation can be found here.

The best way to get to grips with working with the base classes and attributes is to have a quick read of the documentation or to download the #example# and add it to the root of your EPiServer web application.  The example is dependent on PageTypeBuilder!

New Features in v1.2

  • The previous version did not work correctly with EPiServer Commerce.  This was because the various handlers used for commerce intercept most .aspx requests and were bypassing my custom VPP handler for embedded resources.  This has been fixed in this version.
  • A tab index can now be specified when create properties that have property definitions living under different tabs.
  • Issue with commerce and Product picker property fixed.  Basically the product picker inherits PropertyString but does not set the editor control so when ApplyEditChanges is called the property fell over.
  • Minor UI bug fixed.

Installation

The assembly is dependent on EPiServer CMS 6 and onwards.

The easiest way to install the assembly is to get it from the EPiServer nuget feed or you can download it from codeplex.

Example

A full code example can be download from here.  The example demonstrates how you could build an image gallery.  This is also covered in the documentation.

The example below demonstrates how you could create a property that would link to multiple commerce products for recommendations:

  1: namespace ClickAndTalk.CustomProperties
  2: {
  3:     using System;
  4:     using System.Collections.Generic;
  5:     using System.Runtime.Serialization;
  6:     using Mediachase.Commerce.Catalog;
  7:     using ElencySolutions.MultipleProperty;
  8:     using EPiServer.Business.Commerce.UI.Edit.ProductPicker.SpecializedProperties;
  9:     using EPiServer.PlugIn;
 10: 
 11:     [Serializable]
 12:     [PageDefinitionTypePlugIn(
 13:         DisplayName = "Product Recommendations property", 
 14:         Description = "Product Recommendations property - a collection of product recommendations")]
 15:     public class PropertyRecommendationCollection : MultiplePropertyBase<RecommendationCollection, Recommendation>
 16:     {
 17:         public override string GetListItemDescription(Recommendation entity)
 18:         {
 19:             if (entity == null)
 20:                 return string.Empty;
 21: 
 22:             string productId = entity.Product;
 23:             return CatalogContext.Current.GetCatalogEntry(productId).Name;
 24:         }
 25:     }
 26: 
 27:     [Serializable]
 28:     [CollectionDataContract]
 29:     [KnownType(typeof(RecommendationCollection))]
 30:     [MultiplePropertyEntity(
 31:         AddButtonText = "Add new recommendation", 
 32:         ListItemInformationHeader = "Recomendations")]
 33:     public class RecommendationCollection : List<Recommendation>
 34:     {
 35:         public override string ToString()
 36:         {
 37:             return MultiplePropertyHelper.SerializeObject(this);
 38:         }
 39:     }
 40: 
 41:     [Serializable]
 42:     [DataContract]
 43:     [KnownType(typeof(Recommendation))]
 44:     [MultiplePropertyEntity]
 45:     public class Recommendation
 46:     {
 47:         public Recommendation()
 48:         {
 49:             Product = string.Empty;
 50:         }
 51: 
 52:         [MultiplePropertyEntityProperty(Caption = "Product",
 53:             Type = typeof(ProductPickerProperty),
 54:             IsInformationProperty = true,
 55:             SortIndex = 100)]
 56:         [DataMember]
 57:         public string Product { get; set; }
 58: 
 59:     }
 60: }
 61: 
 62: 

When you add the Product Recommendations property to a page type in edit mode you will initially be shown the following:

When you click the "Add new recommendation” button an edit area will appear like the following:

You can then click the “Add” button and the recommendation will be added to the RecommendationCollection. An example is shown of how the properties will be shown when listed.

This is what the editing form will look like when you are editing one of the recommendations within the list:

The code below shows you how you would programmatically work with the property within the page the property has been added too.

  1: protected override void OnLoad(System.EventArgs e)
  2: {
  3:     base.OnLoad(e);
  4: 
  5:     ICatalogSystem catalogContext = CatalogContext.Current;
  6:     RecommendationCollection recommendations = CurrentPage["RecommendedProducts"] as RecommendationCollection;
  7:     IEnumerable<Entry> products = recommendations
  8:         .Select(current => catalogContext.GetCatalogEntry(current.Product));
  9: }

Feedback

Feedback as always is greatly received.  If there are bugs/issues please feel free to email or twitter me @croweman

Oct 05, 2011

Comments

Oct 5, 2011 03:49 PM

This is really nice, and it's something that's been on my todo for a long time, guess I can cross it over for now :-)

Tahir Naveed
Tahir Naveed Oct 6, 2011 04:56 PM

Do you have any idea, how this works with FindPagesWithCriteria or SearchDataSource. e.g. I have created a property containing an image alt text, and image url. Now will FindPagesWithCriteria searches for the image alt text?

Oct 7, 2011 10:35 AM

Hi Tahir

When the entity objects the MutlipleProperty objects are working with are saved they are serialized to Xml.

The only way FindPagesWithCriteria will return matches for the alt text will be if you have criteria with the following condition type CompareCondition.Contained. This will basically do a LIKE ‘%alt text%’ search against the database.

Regarding the SearchDataSource, if you have enabled searching on the page definition property and your SearchDataSource is configured to search pages within the site it will also pick up the image alt text.

Please bear in mind the following:

SearchDataSource – This will find matches in all of the stored xml element values (PropertyData values) but will ignore attribute values which would be the desired functionality.

FindPagesWithCriteria – Because this will do a wildcard search within an xml string you will also pull back matches in the xml structure e.g. element names, attribute values etc etc.

Hope this helps?

Lee

Oct 18, 2011 04:46 PM

I have had a few people ask whether MultipleProperty can be used with LinkCollections.

It can indeed but you will need to decorate your entity class with the following class level attribute otherwise the DataContract serializer will fall over.

[KnownType(typeof(PermanentLinkMapper))]

Please login to comment.
Latest blogs
Accelerating Optimizely CMS and Commerce upgrades with agentic AI (Part 1 of 2)

How Niteco's Upgrade Machine   uses orchestrated AI coding agents to deliver a buildable baseline and a running CMS, then hands over for...

Hung Le Hoang | May 11, 2026

Commerce 15 and CMS 13: Optimizely’s Next Step Toward AI-Powered, Graph-First Commerce

Optimizely is preparing to release Commerce 15 in mid-May 2026 , positioning this as a foundational shift—not just an upgrade. The direction is...

Augusto Davalos | May 7, 2026

The future of Content: Introducing Optimizely CMS 13

Optimizely In the rapidly evolving landscape of digital experience, the "monolithic vs. headless" debate is being replaced by a more sophisticated...

Aniket | May 6, 2026

Hide built in scheduled job from the admin UI

Ok so this probably goes into the not so useful section but late last night I got a veery strong feeling that all projects I am  involved with have...

Per Nergård (MVP) | May 6, 2026

Optimizely CMS 11 Is Out of Support — and the Hard Part of the Upgrade Isn't the CMS

On 10 April 2026, Optimizely formally announced that CMS 11 was out of support — CMS 13 had reached GA on 31 March, and by policy only the two most...

Allan Thraen | May 6, 2026 |

Optimizely SaaS CMS Developer Certification Exam

The Optimizely SaaS CMS Developer Certification is an industry-recognized credential for developers and architects who build scalable, composable...

Megha Rathore | May 5, 2026