Blogpackage - Monthly archive Options
fed
Posted: Sunday, July 06, 2008 9:38:46 PM

Rank: Devotee

Joined: 3/30/2008
Posts: 85
Location: Sweden
Hi,

I have been playing around with the blog-package and everything seems to be working as it should, however. I need a little assistance to generate the "Monthly Archive"-menu list. That lists each month and the number of posts in it. As I have it now in my right-menu, I only list it by Tag.

If anybody can share their XSLT for this, I would really appreciate it!

Thanks.
Dirk
Posted: Sunday, July 06, 2008 10:59:42 PM

Rank: Fanatic

Joined: 9/27/2007
Posts: 403
Location: Belgium
Hi fed,

Here's what I'm using for a family blog:


Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:Stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
<xsl:stylesheet
    version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxml="urn:schemas-microsoft-com:xslt"
    xmlns:umbraco.library="urn:umbraco.library"
    exclude-result-prefixes="msxml umbraco.library">

<xsl:output method="xml" omit-xml-declaration="yes" />

<xsl:param name="currentPage"/>

<!-- Don't change this, but add a 'contentPicker' element to -->
<!-- your macro with an alias named 'nodeId' -->
<xsl:variable name="blogNodeId" select="/macro/nodeId"/>
<xsl:variable name="months" select="umbraco.library:Split('Jan,Feb,Maa,Apr,Mei,Jun,Jul,Aug,Sep,Okt,Nov,Dec',',')"/>

<xsl:template match="/">

<!-- The fun starts here -->

<xsl:if test="count(umbraco.library:GetXmlNodeById($blogNodeId)/node [@nodeTypeAlias = 'umbracoBlogDateFolder' and @level = 3]) > 0">
    <h3>Kunt ge't niet meer vinden? Probeer het archief eens...</h3>
</xsl:if>

<xsl:for-each select="umbraco.library:GetXmlNodeById($blogNodeId)/node [@nodeTypeAlias = 'umbracoBlogDateFolder' and @level = 3]">

<xsl:sort select="@nodeName" data-type="number" order="descending" />
        
    <a href="{umbraco.library:NiceUrl(@id)}"><b><xsl:value-of select="@nodeName"/></b></a>:

    <xsl:for-each select="./node [@nodeTypeAlias = 'umbracoBlogDateFolder' and @level = 4]">
    
    <xsl:sort select="./@nodeName" order="descending" />
    <xsl:variable name="month" select="./@nodeName"/>

    <a href="{umbraco.library:NiceUrl(@id)}">
        <xsl:value-of select="$months/value[number($month)]/text()"/></a>
    
    <xsl:if test="position() &lt; last()-1">
        <xsl:text>,&nbsp;</xsl:text>
    </xsl:if>

    <br/>
    
    </xsl:for-each>

</xsl:for-each>

</xsl:template>

</xsl:stylesheet>


Basically, I'm sending in a node Id, which is the top level node for my blog in the content tree, and perform a double for-each loop. First will iterate the date folders at 'year' level, the second inner loop is iterating the date folders at 'month' level.

Don't bother about the Dutch text, should replace that of course :)

Have also created an array holding the Dutch abbreviates for months, making it easier to replace the month number by its text counterpart.

Hope that helps,
/Dirk




level 1 certified - umbraco blog at netaddicts.be
fed
Posted: Monday, July 07, 2008 1:14:19 AM

Rank: Devotee

Joined: 3/30/2008
Posts: 85
Location: Sweden
Thanks a lot Dirk! will try it out!

Edit:
I tried it out and it works perfectly. One last question, and then I will stop nagging :)

How does your XSLT and template for the umbracoBlogDateFolder look like?

Thanks again :)
Users browsing this topic
Guest


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.