Publish DateTime for BlockData

Vote:
 

Hi

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.

Thanks

#113555
Nov 24, 2014 16:29
Vote:
 

Could be useful for your blocks:

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

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

#113585
Nov 25, 2014 10:28
Vote:
 

Sorry, that was for pages. Try 

IModifiedTrackable
#113598
Nov 25, 2014 13:26
Vote:
 

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?

#113600
Edited, Nov 25, 2014 13:35
Vote:
 

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.

#113604
Nov 25, 2014 13:50
Vote:
 

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

#113612
Nov 25, 2014 15:57
Vote:
 

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 - https://epiboost.codeplex.com/

#113619
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.