Pages in EPiServer only exist virtually - there is no physical file for their existence. They are simply based on one of the page types and the database keeps a record of any respective data. A single template can be used to create several pages that will all look the same but contain different information. This is a nice feature but what happens if a page is created against template X and we want to use template Y in the future? We asked the same question to an EPiServer specialist who didn't really have an answer. The best he could come up was to update the database manually; in other words - there is no built-in functionality. Below is some SQL that can be run against the EPiServer database in order to modify an existing page's page type:
declare @PageID int
set @PageID = X
declare @PageTypeID int
set @PageTypeID = Y
declare @LinkURL nvarchar( 255 )
select @LinkURL = [Filename] from tblPageType where pkID = @PageTypeID
set @LinkURL = @LinkURL + '?id=' + cast( @PageID as nvarchar )
update tblPage set fkPageTypeID = @PageTypeID, LinkURL = @LinkURL where pkID = @PageID
update tblWorkPage set LinkURL = @LinkURL where fkPageID = @PageID
delete from tblWorkProperty
where fkWorkPageID in ( select pkID from tblWorkPage where fkPageID = @PageID )
Simply replace X with the page ID and Y with the page type ID.
2 comments:
What happens if the two pagetypes have different property definitions? :-)
Actually, I believe that this feature will be part of CMS 5 SP2, sometime later this year. It has been on the wishlist for a long time. Looking forward to it.
I guess the page would lose all the old property values and you'd start from scratch again.
We recently did a batch update and had no such problems. The only issue we had was that we had to go through and manually re-publish all of the modified pages. If we didn't, you'd get an error when trying to view one of the pages.
Post a Comment