How to assign the property value, based on the folder where the page is created

H F
H F
Vote:
 

Hello, 

I wonder how, at the moment of page instance creation, how can I assign a value to some page's property, the value based on the folder name where this page instance is created?

Something related to '

public override void SetDefaultValues(ContentType contentType)'?

thank you

#199616
Dec 03, 2018 22:49
Vote:
 

The SetDefaultValues method allows you to set default values for your content but this is executed before the content is saved in the repository. So you need to hook into the content created event: https://world.episerver.com/documentation/class-library/?documentId=cms/11/5B685F5 which would allow you to access the parent (folder) and update your content accordingly. You can do this in an Episerver intialisation module: https://world.episerver.com/documentation/developer-guides/CMS/initialization/Creating-an-initialization-module/ 

#199618
Dec 03, 2018 23:11
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.