Creating custom property question


Hello world!

I'm new to the development of EPISERVER and have a question(and help!) regarding the creation of Custom Property:

I need to create a Custom Property containing a list of existing Properties -> i've created a new Custom Property but I do not know how to add an existing Property List and continue with this.

For example:

1) I have next Properties (all I can define separately, works fine): "Recurrence type, Recurrence every, Recurrence weekday, Recurrence day, Recurrence month and Recurrence finish date".

2) I've created a new Property named 'Recurrence Settings' - My purpose to do so clicking on 'Recurrence Settings' will open a window(like a pop-up) where I can see list of properties above.

3) I built template contains elements of pop-up showing a list of Property but they are not linked to Real Properties, just html page.

4) When clicking on 'Recurrence Settings' - opens a pop-up window that contains these elements.

5) I wrote a javascript that allows to manipulate the elements in the pop-up window (to show or hide different elements depends to Recurrence type, for example).

6) I can get a values (in javascript) from different inputs but I'm stucked here - how to pass them? 

I thought I should put real Property List to pop-up window and so to solve the problem?

Any idea and help are welcome,

Leonid. :)

May 08, 2016 13:35

Hi Leonid.

Basically, you have two different options to achieve your end goal - supporting a set of properties as a re-usable property across content types.

Simple approach.
Episerver normally recommends to combine your shared set of properties via a BlockType and then use that as an in-line property on your ContentTypes. It would e.g. mean that you could do something like this:

[ContentType(DisplayName = "TeaserBlock", GUID = "38d57768-e09e-4da9-90df-54c73c61b270", Description = "Heading and image.")]
    public class TeaserBlock : BlockData
                    Name = "Heading",
                    Description = "Add a heading.",
                    GroupName = SystemTabNames.Content,
                    Order = 1)]
                public virtual String Heading { get; set; }
                    Name = "Image", Description = "Add an image (optional)", 
                    GroupName = SystemTabNames.Content,
                    Order = 2)]
                public virtual ContentReference Image { get; set; } 
 [ContentType(DisplayName = "ArticlePage", GUID = "b8fe8485-587d-4880-b485-a52430ea55de", Description = "Basic page type for creating articles.")]
    public class ArticlePage : PageData
                    Name = "Teaser",
                    GroupName = SystemTabNames.Content,
                    Order = 10)]
                public virtual TeaserBlock Teaser { get; set; }

As you can see, my block type "TeaserBlock" can be used when defining a PageData class. "TeaserBlock" would be your "Recurrence Settings". Be aware that your "Recurrence Settings" has to be BlockData and it will not be presented via a popup when editors are accessing the fields.

Advanced approach - which sounds like the approach you are taking as per your description
The other option you have is more complicated, as it requires you to create a custom PropertyData, EditorDescriptor and DOJO widget. It will enable you to fully customize how your type is persisted and authored. Doing these things has been covered by numourous blog posts and I can only recommend you to be inspired by e.g. my posts here:  

They introduce you to creating a custom PropertyData, EditorDescriptor and DOJO widget. It though still requires some effort to tie the loose ends - e.g. create the pop-up driven widget for your specific need.
I hope the post about "Get predictive Time-zones in DateTime Properties" can help you with your question regarding how to pass the data back to Episerver. In short, its done via this._setValue(value);

Hope my answer helped you get further. I would normally go for the Simple approach and avoid extending Episerver unnecessarily. 

Casper Aagaard Rasmussen

May 08, 2016 16:24

Hello Casper,

Thanks for the reply, it would be interesting to know the additional methods.
I've solved the problem with my way - I transmits data via JSON to the controller where processes them as needed.

But in the future if I will have to do something similar, I'll use your method.


Leonid Berman

May 18, 2016 10:01
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.