Try our conversational search powered by Generative AI!

Eventhandlers in CMS5

Vote:
 

Hi,

We are migrating code from 4.62 to CMS 5 and have som issues with the event handlers.

In the PublishedPage event (or the rest of the event flow for that matter) we make use(ie read) of the e.Page.Saved date, only now in CMS5 this date is not updated to the new saved date. It contains the date from when it was previously saved! I've also looked in the SavedPage event, but to no avail.

The Saved date is only updated after the entire event flow that we can hook into is done, atleas so it seems.

 In the debug process I also tried the following in the PagePublished event:

e.Page.PageName = "Some new pagename";

This does not toss a read-only exeption as I'd expect(page being published and all), however the new name is ignored.

If some one can enighten me on this I'd be really greatfull!

 

Update:
If I do a GetPage(e.Page.Pagelink) in the PublsihedPage event , that PageData object contains the correct Saved date.
This smells like a bug in what is being passed in the e.Page object.

 

Regards,
Morten

#29514
Apr 30, 2009 10:39
Vote:
 

Hi,

Instead of using PublishedPage event you should use PublishingPage event. This is because the PublishedPage event will always show you the old date not the new one.

#30280
Jun 10, 2009 15:36
Vote:
 

Hi Ahsan and thank you for your answer.

Could you please enlighten me as the the reasoning for showing the old dates in the PublishedPaged event? Othere proerties show the new values.

And why is it possible to do the following in the PublishedPage event:
e.Page["Someproperty"] = "Some string"; without getting a readonly error?
The page is publsihed and therefor it should be readonly right? (Nothing gets commtited, but I'd assume it should throw an exeption)

Regards,
Morten Sørby

#31179
Jul 07, 2009 10:05
Vote:
 

This behaviour has always been somewhat unclear, and my recommendation has always been to do a GetPage() in the "after" events (Published/Saved etc.). You usually want to work with the new data at this point, and getting it fresh from the database is the only way to ensure it is updated.

#31189
Jul 07, 2009 12:05
Vote:
 

Hi Steve,

You might call it unclear, I'll go with inconsistent ;-)

I just seems wrong, that one has to fetch it from the database when the e.Page is in fact passed to the event.
It is redundant to have to fetch it with code like this GetPage(e.Page.PageLink), that feels bad and makes the eventmodel inconsistent.

How is this from a performance perspective? Is the data in the data cache at this point? Or will our call to GetPage be forced to read the data from the database as the first fetch of this new pagedata object?

//Morten

#31190
Jul 07, 2009 12:18
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* 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.