Home  ›  BLOG  ›  2008  ›  5  ›  18  ›  List categories of Umbraco blog
List categories of Umbraco blog
Sonntag, 18. Mai 2008, Christoph Ertl

I'm not sure if I deleted the xslt file or am just kind a blind. But I found nothing providing me a listing of all available categories and their count of occurrence. So here is my solution.

First of all we have to know the id of the data type used for the categories. Execute the following statement against the database and note the resulting dataTypeId.

SELECT dataTypeId FROM cmsPropertyType
WHERE alias =
'categories'

The resulting id (in my case: 1094) is used in the xslt macro to get all predefined values. The macro iterates over all predefined values of the dataType with the id 1094 and counts all nodes of type umbracoBlogPost containing this predefined value.

<xsl:for-each select="umbraco.library:GetPreValues(1094)/node()">
<
xsl:sort />
<
a>
  <
xsl:attribute name="href">
    <
xsl:text>/blog.aspx?filterBy=</xsl:text><xsl:value-of select="current()"/>
  </
xsl:attribute>
  <
xsl:value-of select="." />
</
a> (<xsl:value-of select="count($currentPage/ancestor-or-self::node/descendant-or-self::node [@nodeTypeAlias = 'umbracoBlogPost' and string(data [@alias='umbracoNaviHide']) != '1' and contains(./data [@alias='categories'], current())])" />)

  <br/>

</xsl:for-each>

To get the macro work properly you have to use the id of the dataType as described above and correct the url to point to the page supporting the filterBy parameter.


0 Kommentare für “List categories of Umbraco blog”

    Leave a comment


    Not shown. Will only display your Gravatar picture from http://www.gravatar.com/


    (optional - remember http://)


    Enter the characters from the image. (used to avoid spam posts)