Setting default value to Name of page?

Vote:
 

Hi,

I am trying to set one of my fields to default to the name of the page item created.  The field is for breadcrumb title, so it logically makes sense to default this to the page name.

I've tried overriding SetDefaultValues on my Page model, but it seems that this function is called before the user is prompted for the page name.

Is this possible in episerver?

#194810
Jul 03, 2018 20:45
Vote:
 

Previously to do this I have needed to hook up on the ContentCreated event (or if it was ContentCreating, unfortunately I don't remember).

Unless in your view model you create a fallback so if the Breadcrumb does not have a value, use the Page Name instead.

#194811
Jul 03, 2018 22:41
Vote:
 

Hey, Dylan,

Given that you already have the value for PageName that breadcrumb name should fallback too, I wouldn't write the same value to the database, but rather do what Alf proposed. When getting the breadcrumb, have something like BreadcrumbName ?? PageName.

If it was more complex than that, if you had some difficult logic to choose the BreadcrumbName, Creating or Publishing would do the work (since in these events, the content is writable). However, "BreadcrumbName ?? PageName" will hardly give you any performance reason to do that.

BR,
Marija

#194916
Jul 08, 2018 15:49
Vote:
 

Thanks!  This makes sense!

#194927
Jul 09, 2018 14:49
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.