Try our conversational search powered by Generative AI!

How to update old page type properties

A
A
Vote:
 

How do you convert old page type properties to new ones?

Say I have this class

public class HomePage : GlobalBasePage
{

[Display(Name = Global.Constants.VIDEOS,
GroupName = Global.Constants.VIDEOS
)]
[AllowedTypes(typeof(VideoFile))]
public virtual ContentArea VideoFiles { get; set; }


[Display(Name = "Heading")]
public virtual string Heading { get; set; }
}

and want to cahnge the string to XhtmlString and VideoFiles to a certain blcok

public class HomePage : GlobalBasePage
{

[Display(Name = Global.Constants.VIDEOS,
      GroupName = Global.Constants.VIDEOS
)]
[AllowedTypes(typeof(VideoAndTextBlock))]
public virtual ContentArea VideoAndTextBlocks { get; set; }
   
     
[Display( Name = "Heading")
public virtual XhtmlString Heading { get; set; }

}

If I go to episerver, log in and view this page in edit mode, these new property types do not reflect.

Why?

And what is the best way to convert them to the new types?

#187744
Edited, Feb 01, 2018 17:59
Vote:
 

did you try to add migration step for `VideoAndTextBlocks` property?

#187848
Feb 05, 2018 9:28
A
Vote:
 

@Valdis, I'm new to episerver and do not know what migration step you are referring to.

#187895
Feb 05, 2018 17:07
Vote:
 

I had these in mind - https://world.episerver.com/documentation/class-library/?documentId=cms/7/49ffb44e-34fc-c91a-8cb3-e107c036767a

Also collegue of mine blog post would become helpful - https://www.patrickvankleef.com/2015/08/18/episerver-content-migration/

#187896
Feb 05, 2018 17:54
A
Vote:
 

This seems wayyyy too involved/complex to simply update a property type. 

Isn't there a way to simply update a page type in the epi databasae?

Why did Episerver make this so complex/cumbersome?
Did they think developers would never need to update a property on a page type?

#187897
Feb 05, 2018 20:04
Vote:
 

If you made the changes in code you can go into the CMS->Admin->Content Type->Page Types and apply your changes, IF you don't mind data loss. If I am correct on your properties there should be a button "Revert to Default" that will do exactly what you are asking for.

In code you could load the type from IContentTypeRepository and attempt to modify it. Again the function ResetContentType might do exactly what you want but i have never tried it myself.

This is during -development- where data loss isn't an issue. If you have deployed the old type into a staging or production environment you need to use migration steps.

It is cumbersome to avoid data loss when altering data types in an sql database, it has more to do with sql than Episerver.

#187926
Feb 06, 2018 14:46
A
Vote:
 

@Erik, thanks!
That was exactly what i was looking for - as you said, it's dev mode so no harm in losing some content here and there. 
I was mostly frustrated with not seeing the UI update to the new property type.

Thanks again

#187933
Feb 06, 2018 18:56
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.