Virtual Happy Hour this month, Jun 28, we'll be getting a sneak preview at our soon to launch SaaS CMS!

Try our conversational search powered by Generative AI!

Few stupid questions


1. Is there any way to have properties inside interface, i need for example IMenu ISocialWidgets IColors and than each will have few properties, then i can inherit correct ones on page types that need to have respective properties.

2. Is there any way to have property on page type that is not picked up by Episerver, for example some integer property to stor count, or i should create pageview model for each page type ?
3. Is there any way to pull macro, or maybe even block into XhtmlProperty in edit mode ?

Jun 17, 2016 7:35

1. Yes! I recommend that. I usually have a few interfaces for page types that can appear in listings, have SEO information etc. Then when you fetch all children or similar you can check if they implement that interface and cast it to that. Episerver 7+ is a great CMS in that aspect since you can work with both inheritance and interfaces with content types. You can write beautiful and SOLID code without a bunch of magic strings and if if if...

2. You can have properties that are stored in Episerver but not visible to editor. If you have have a property that depends on current user however you should always store that in a view model instead since pages are like a static class and shared between users. If you store something like the number of user comments or similar in a normal.NET property on the content type class, that information will be visible for other users as well even though it's not stored in Episerver. So be a bit careful of adding properties to page types that isn't "normal" Episerver properties. Page View Model exist for that reason. Use that one.

3. Yup. You can drag blocks into xhtml areas. You can also use dynamic content inside xhtml areas but normally blocks are better if you have Episerver 7+:)

Edited, Jun 17, 2016 7:50

@Daniel Thx for fast answer !
Could you give me code examples for questions 1 and 2.
For 1 i wanted to create interface with

public virtual string properti1 {get; set;}

But i can't put virtual in Interface, and as i figure EPiServer needs virtual in order to hook up?
For 2 how do i hide property from editor ?

Thx again

Jun 17, 2016 8:02

You can just skip the virtual and public keywords in interface.

Public interface IHasSeoInformation


String PropertyName{get;}


To hide a property you can use the attribute 


Jun 17, 2016 8:29

Thank you !!

Jun 17, 2016 8:44
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.