Try our conversational search powered by Generative AI!

Publish DateTime for BlockData



We're looking to move images from EpiServer into a CDN, so we want to edit URLs contained in a BlockData object before they are used. (This part we know how to do).

But we also want to add the published date onto the URL so that the CDN will see each update as a new resource and update straight away. How can we get the associated Publish date time information for a URL inside a BlockData.

I've seen that there is a "Saved" property on the PageData object which seems to have the correct date time information that we want, but I don't know how to access this in relation to the URL.


Nov 24, 2014 16:29

Could be useful for your blocks:

public abstract class BaseBlockData : BlockData
    public DateTime LastModified
            var changeTrackable = this as IChangeTrackable;
            return changeTrackable != null ? changeTrackable.Saved : DateTime.MinValue;
Nov 24, 2014 22:09

Thanks for the reply Valdis, but this doesn't seem to work. 

changeTrackable is always null, as there is nothing in BlockData's inheritance heirachy which implements IChangeTrackable

Nov 25, 2014 10:28

Sorry, that was for pages. Try 

Nov 25, 2014 13:26

IModifiedTrackable only returns a bool, we'd like to read the DateTime of the last update/publish

Is there a way to find the newest PageData object that the URL or BlockData is part of?

Edited, Nov 25, 2014 13:35

A shared block implements IChangeTrackable, even if you can't see it by looking at The BlockData class. Read more here.

So converting to IChangeTrackable should work, and you can get the Saved property. Converting to IVersionable will also work, if you want to get the StartPublish property. If you need the name property, simply convert to IContent.

Nov 25, 2014 13:50

Yes, I forgot that IChangeTrackable was injected by Castle proxy. So this cast is valid only in runtime. Try it out.

Nov 25, 2014 15:57

It seems like we are using local blocks rather than shared blocks as described here

We are not creating the BlockData using IContentRepository

I've looked through the block's members in the debugger at runtime and it doesn't seem to have been updated with the information we need

Also we are using version 7.0.586.1 along with the EpiBoost Library -

Nov 25, 2014 17:20
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.