Try our conversational search powered by Generative AI!

Episerver CMS 11.7.1: Add additional property to base pagetype in initialization

Vote:
 

Is this even possible?

We have so many pages which inherits from our basepage type. Which cannot be modified or change. 

We want to add some additional fields to base apge so every page that inherits it gets it. Is it possible to do this in initalization isntead of doign it in admin view?

#196741
Sep 10, 2018 18:31
Vote:
 

Hi,

Why you can't modify base page class add those properties?

#196751
Sep 10, 2018 22:01
Vote:
 

We have it in a separate project. Which cannot be modified. And because it is used by all our pages I would like to add the properties to the base page type.

#196752
Sep 10, 2018 22:21
Vote:
 

You could do it but you would lose the ability to access the newly added property in a strongly typed way. You must be using the base type yourself, either to inherit in your own models or use directly in the views? If so then I would create a "extended base type" that inherits from your standard basepage type. Then change any references in your project from basepage type to use "extended base type". You can then add the properties you require and also access the new property(s) in a strongly typed way.

Otherwise if you really wanted do this in an init module (I would not advise you to do so) then you can modify the code here: https://github.com/davidknipe/InsightFormFieldMapper/blob/master/InsightFormFieldMapper/Init/FormToInsightMappingInit.cs#L34 and change line 37 to be your basepage type and add whatever properties you need there.

David

#196753
Edited, Sep 10, 2018 23:57
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.