Easy way to count total content type objects?

We are looking into auditing our information. How can we easily count pieces of content per type?

We are able to list content type with this: #set($iApiListResponse = $core_v2_contentType.List())

Looking to then count content per content-type-id

Parents
  • Hi Stephen, you could try using search  to help with this and using the contenttype as a facet as your example shows velocity this snippet might help you 

    ## expose facet on content type
    #set ($contentTypeFacets = "contenttypeid,count,50,0,1")
    
    ## simple query as we are only interested in the facets 
    #set ($contentTypesQuery = "%{}")
    $contentTypesQuery.Add("Query", "*")
    $contentTypesQuery.Add("PageSize", 1)
    $contentTypesQuery.Add("PageIndex", 0)
    $contentTypesQuery.Add("FieldFacets", $contentTypeFacets)
    
    #set ($searchResults = $core_v2_searchResult.List($contentTypesQuery))
    
    #foreach ($facet in $searchResults.FieldFacets)
       ## do somsmthing with the values 
       $facet.Fieldname  $facet.FieldValue $facet.DocumentCount
    #end

Reply
  • Hi Stephen, you could try using search  to help with this and using the contenttype as a facet as your example shows velocity this snippet might help you 

    ## expose facet on content type
    #set ($contentTypeFacets = "contenttypeid,count,50,0,1")
    
    ## simple query as we are only interested in the facets 
    #set ($contentTypesQuery = "%{}")
    $contentTypesQuery.Add("Query", "*")
    $contentTypesQuery.Add("PageSize", 1)
    $contentTypesQuery.Add("PageIndex", 0)
    $contentTypesQuery.Add("FieldFacets", $contentTypeFacets)
    
    #set ($searchResults = $core_v2_searchResult.List($contentTypesQuery))
    
    #foreach ($facet in $searchResults.FieldFacets)
       ## do somsmthing with the values 
       $facet.Fieldname  $facet.FieldValue $facet.DocumentCount
    #end

Children
No Data