7

I'm currently working on a event handler. This will, on a save-event, save the latest revision date of the page and its components into a custom database. It is working, but I'm facing some performance issues.

Let me give you an example of how it works:

If a component is saved/updated (changes are made), then I want to update all pages using this component in my custom database.

Basic blueprint setup: 200 contains components

400 translation publication for components (inherent components from 200)

500 master publication for pages

600 local site publication inherent components from 400 and pages from 500)

So lets say we have component, "X", in 200. This component is included in in a page in 500 and localized in 400 (let us call it X(l)). The page in 600 is NOT localized ( i.e it will use the component X(l) instead of X)

So now to my question: In my save event handler, I check what pages X(l) are included in by using :

var filter = new UsingItemsFilter(component.Session)
        {
            IncludeLocalCopies = true,
            ItemTypes = new[] { ItemType.Page }
        };

But this will only give me references to pages from 500. So then I (which feels kind of stupid) do the following: create a TCM ID of all pages in child publications(by looping over them) that inherent this page (now I'm using some psuedocode-like coding):

foreach(var 500page in foundPages)
foreach(var publication in publications){
 if(subject.Session.IsExistingObject(
 new TcmUri(page.Id.ItemId,page.Id.ItemType,publication.Id.ItemId)
 ))
 {
  someListThatWillContainAllChildPagesFrom500.Add(TheAboveTcmUri);
 }
}

And then for each page, check the components in that page, and finally save this state to my custom database.

So the question is: is there a way to query for all pages that make use of the localized component by using the TOM.NET API (no not CoreServiceClient)?

Is there a better way to find child publications of a publication, so I only need to check for pages in the childPublication?

And yes, I have tried the :

            if (pub.HasChildren)
            {
                var childs = pub.GetUsingItems(new UsingItemsFilter(subject.Session) { 
                    ItemTypes=new []{ItemType.Publication}
                });

which only throws : not implemented exception.

Be aware that this is on a 2011 implementation

Br Martin

3 Answers 3

4

You could use the good old GetBluePrintChain(BluePrintChainFilter filter) for this maybe? This gives you all child pages based on the current page you're processing.

As a quick example:

BluePrintChainFilter b = new BluePrintChainFilter(engine.GetSession());
b.Direction = BluePrintChainDirection.Down;
foreach(RepositoryLocalObject r in page.GetBluePrintChain(b))
{
    log.Debug(r.WebDavUrl);
}
3
  • I see what you mean, but blueprintChainFilter does actually not retrive shared stuff, only the first item in the shared chain. What i want, is something like for a given component, give me all the(shared) pages using this (shared) component, from all publications.
    – Berka
    Commented Apr 16, 2013 at 13:23
  • 1
    Okay, so finally i solved this ! :)
    – Berka
    Commented Apr 23, 2013 at 6:43
  • How did you do it? Care to share that with us? :)
    – Raimond
    Commented Apr 23, 2013 at 7:18
3

Of course, it depends on exactly what you are trying to do, but Tridion already does something similar when it resolves. You have API access to Tridion resolving via Tridion.ContentManager.Publishing.Resolving.ResolveEngine

3

The following code sample should give you the shared items of a specific local/localized item along with the item. BluePrintNodesFilter was introduced in 2013, however in earlier version BluePrintFilter should work in similar way.

SystemManager systemManager = session.SystemManager;
BluePrintNodesFilter filter = new BluePrintNodesFilter(session)
{
    BaseColumns = ListBaseColumns.Id,
    ForItem = page
};
IEnumerable<BluePrintNode> allNodes = systemManager.GetBluePrintNodes(filter);
IEnumerable<RepositoryLocalObject> sharedAndLocal = (from node in allNodes
    where node.Item != null
    where node.Item.OwningRepository.Id == page.OwningRepository.Id
    select node.Item).ToArray();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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