|Number of votes:||4|
About two and a half years ago during some down time at a previous agency I decided to build a control which allowed you to easily create custom properties that comprised of other properties.
I did this in an approach similar to PageTypeBuilder by allowing you to decorate entity classes and properties with specific attributes.
This was probably around the same time in which the Itera.MultiProperty was being developed.
Just recently as I have a lot of free time during my commute to and from work every day I decided to revisit the project again and enhance it.
To create custom properties using ElencySolutions.MultipleProperty you basically create your entity objects and decorate the class and properties with various attributes.
You then create a class which inherits MultplePropertyBase, supply the class some generic arguments and hey presto you can edit your entities.
The property class will serialize the entity objects to xml using the DataContractSerializer and will return the deserialized entity value from the Value property.
I am not going to document a complete usage guide in this post but I will show a few code samples and screen dumps.
To use the code sample just copy the MultiplePropertyExample folder within the zip file into a local public templates site. The Sample is dependent on PageTypeBuilder.
The sample contains some entity classes, property classes and a couple of PageTypeBuilder page types.
The sample demonstrates how you would go about building an image gallery. One page type demonstrates a single gallery with multiple images where as the other page type demonstrates multiple galleries each with multiple images.
The code below will show a simple example of how you would create an image link property using ElencySolutions.MultipleProperty.
For more of an in depth example please download the sample code.
Below is an example of how you would define an ImageLink entity object.
Once the entity object has been created you can then define your property in the following way.
To use the property within a PageTypeBuilder PageType class you would define it in the following way.
Below are some screen dumps of what an editor would be presented with when using the custom properties.
Screen Dump One – Image Gallery Sample
Screen Dump Two – Image Galleries Sample
Screen Dump Three – Property Copying
To use ElencySolutions.MultipleProperty you will need to reference the ElencySolutions.MultipleProperty assembly from your web application project. You will also need to add a reference to System.Runtime.Serialization.
The assembly is dependent on EPiServer CMS 6.
The assembly and sample code can be downloaded from codeplex.
The usage guide contains more information about using the assembly but I have listed some additional features of the assembly here.
I know there are assemblies out there that do the same thing but I wasn’t that keen on how I had to work with them. Therefore I created one that suits my needs .
Give it a go if you like and I hope you will find it useful.
I am always eager to receive feedback good and bad.
Please feel free to email or twitter me with any feedback @croweman or comment on the blog post
Although I have tested the assembly and am happy with it’s functioning there may well be little bugs that I have not spotted. Please give it a thorough test before releasing it to the production environment and log any issues on codeplex.