I am using the core service (Tridion 2013 (no SP)) to get some stats and I am experiencing a weird behavior. In the system there are multiple pages (494) using the same page template. Using the core service I run this code:
string id = "tcm:73-18028-128";
var wuFilter = new UsingItemsFilterData();
//wuFilter.IncludeLocalCopies = true;
//wuFilter.IncludeVersionsColumn = true;
wuFilter.IncludedVersions = VersionCondition.OnlyLatestAndCheckedOutVersions;
//wuFilter.BaseColumns = ListBaseColumns.Extended;
wuFilter.ItemTypes = new ItemType[]{ItemType.Page};
var xml = Tridion.GetListXml(id, wuFilter);
XNamespace ns = xml.Name.Namespace;
Debug.WriteLine("Pages Using Template "+id+":" + xml.Descendants(ns+"Item").Count());
That gives me 87 pages.
When I select such page template in the CME and do a "Where used", I also get 87.
Now, If I get all the pages in that publication and count those using the previous PT, I get 494. I used this code for this:
var filter = new RepositoryItemsFilterData ();
filter.Recursive = true;
filter.ItemTypes = new ItemType[]{ItemType.Page};
var otherXml = Tridion.GetListXml("tcm:0-73-1", filter);
XNamespace ns2 = otherXml.Name.Namespace;
int counter = 0;
foreach (XElement node in otherXml.Descendants(ns2 + "Item"))
{
string id2 = node.Attributes("ID").FirstOrDefault().Value;
PageData page = Tridion.Read(id2, new ReadOptions()) as PageData;
if(page.PageTemplate.IdRef == id){
counter++;
}
}
Debug.WriteLine("Pages Using Template "+id+":" + counter);
Anybody experienced weird behavior with "Where Used"?