I need to retrieve the page or pages that are published and the component presentation of the page (or pages) contain a certain component. If a component exists on multiple pages, I would like to know which one is the closest to the root. How can I achieve this using queries in TOM.Net?

  • 1
    A good place to start would be to look at the API documentation. Jun 29, 2018 at 15:31
  • 1
    You say that you want to achieve this using TOM.Net. Where will this code run? For example, are you doing this within templating code (executed when an item is published) or within the Events System, maybe? Some more information may help to determine the best approach and whether TOM.Net is even the right solution. Jun 29, 2018 at 15:37
  • @JonathanWilliams This is going to be on a TBB and run at the runtime. This code won't run at the rendering time.
    – Payam
    Jun 29, 2018 at 15:41
  • 1
    If it will be a TBB, then it will most certainly run at rendering time.
    – Atila Sos
    Jun 29, 2018 at 16:59
  • @AtilaSosI meant publish time. The TBB is going to run at the publish time.
    – Payam
    Jun 29, 2018 at 18:26

2 Answers 2


I’m a bit confused by your comment “this is going to be on a TBB and run at the runtime. This code won’t run at the rendering time.”

In general, TBB code runs at rendering time. And the reason why Jonathan asked for it, is because only templating and event handler code is supposed to use the TOM.NET (rather than the Core Service).

Anyways, assuming that you want to use the TOM.NET: have a look at method IdentifiableObject.GetUsingItems in the API reference docs.

With this method, you can find the (published) Pages on which a given Component is used. Distance from the root can be determined using Page.PublishLocationPath.


What have you tried so far? I'm asking because this question is a "do my homework instead of me" type, so there is little chance that someone will write your code instead of you. Best we can do is give you some hints, and then using the API found HERE you can easily put together your own code. For debugging purposes you can attach to the Template Builder process, or do it the hard way with log statements.

  • To retrieve the published pages you can use the PublishedItemsFilter class
  • To see whether a Component is used on a Page, you can either look at the ComponentPresentations of a Page, or you can use the 'where used' functionality with the UsingItemsFilter on the relevant Component
  • To find the one Page closest to the "Root", you can compare their Path or PublishLocationPath property. Or do a search by item type Page starting from the Root and going deeper each iteration

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.