Skip to main content

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

Let me give you an example, for of how it's workingit 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

400 translation publication for components (inherent components from 200) 500

500 master publication for pages 600

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

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

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

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

butBut this will only give me references to pages from 500. So what i then doI (which feels kind of stupid) is todo the following: create a tcm idTCM ID of all pages in child publications(by looping over them) that inherent this page (now imI'm using some psuedocodelikepsuedocode-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 by to query for all pages, that make use of the localized component, by using the TOM.NET apiAPI (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, iI 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

I'm currently working on a event handler, which will on save-event, save the latest revision date of the page and it's components into a custom database, and this is working, but i'm facing some performance issues.

Let me give you an example, for how it's working:

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, X is localized in 400 (let us call it X(l)) and the page in 600 is NOT localized ( i.e it will use the component x(l))

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 what i then do (which feels kind of stupid) is to create a tcm id of all pages in child publications(by looping over them) that inherent this page (now im using some psuedocodelike 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 by 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

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

Tweeted twitter.com/#!/StackTridion/status/322496108897132545
Source Link
Berka
  • 171
  • 4

Get shared pages using localized component

I'm currently working on a event handler, which will on save-event, save the latest revision date of the page and it's components into a custom database, and this is working, but i'm facing some performance issues.

Let me give you an example, for how it's working:

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, X is localized in 400 (let us call it X(l)) and the page in 600 is NOT localized ( i.e it will use the component x(l))

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 what i then do (which feels kind of stupid) is to create a tcm id of all pages in child publications(by looping over them) that inherent this page (now im using some psuedocodelike 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 by 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