5

I'm trying to get an overview of a page's history using core services. I require data for all the versions of the page, this includes a couple of things, but I am having difficulties with the page's component presentations.

Here is my code so far:

FullVersionInfo fullVersionInfo;
VersionsFilterData versionsFilter = new VersionsFilterData();
IdentifiableObjectData[] pageVersionList = client.GetList(testPageId, versionsFilter);

foreach (IdentifiableObjectData identifiableObjectData in pageVersionList)
{
    PageData pageData = client.Read(identifiableObjectData.Id, new ReadOptions()) 
                        as PageData;

    foreach (ComponentPresentationData componentPresentationData 
             in pageData.ComponentPresentations)
    {
        fullVersionInfo = client.Read(componentPresentationData.Component.IdRef, 
                                      new ReadOptions()).VersionInfo as FullVersionInfo;

        log.DebugFormat("Component id: {0}   version: {1}", 
                        componentPresentationData.Component.IdRef, fullVersionInfo.Version);

        fullVersionInfo = client.Read(componentPresentationData.ComponentTemplate.IdRef,
                                      new ReadOptions()).VersionInfo as FullVersionInfo;

        log.DebugFormat("Component template id: {0}   version: {1}",
                        componentPresentationData.ComponentTemplate.IdRef,
                        fullVersionInfo.Version);
    }
}

The problem is that I'm always getting the latest versions of the components and the component templates, instead of the versions used on specific versions of a page. Does anybody know how this should be done? In CME when viewing a page's history it can be compared with previous versions, so I believe this to be possible as well.

Any help would be appreciated.

| improve this question | | | | |
  • 1
    @user978511 explains the challenge with the Core Service. If your use case is for review, alternatives to capture this information include a Storage/Deployer extension, SDL Archive Manager, or Workflow's Snapshot option with Auditing turned on. – Alvin Reyes Jul 24 '14 at 23:33
  • Thank you for the suggestions, and it is indeed for reviewing purposes. I will look into the solutions you proposed. – Atila Sos Jul 25 '14 at 11:39
3

The thing is that page and components are decoupled. It means that page only knows if certain component presentation is on the page and not its version.

If you want, you may get versions of component and component template which were in use during this version of page. For example: version 2 of page was used from 1st till 15th of August, this time frame corresponds to versions 3-6 of component and version 2 of component template. If this is good enough for you - you need to go over all of the components and templates versions and do the matching yourself. Keep in mind that page also has no idea of the page template version.

| improve this answer | | | | |
  • Thank you for your answer and the idea for a workaround with the dates. – Atila Sos Jul 25 '14 at 11:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.