This project is read-only.

Sorting the Recent Posts and Archives

Topics: Enhanced Blog Edition
Nov 13, 2007 at 12:32 PM
I am in the final stages of deployment, so I loaded a bunch of posts that I have been saving up. I changed the Published Date to reflect the day that I originally posted the information.

Both the Recent Posts and Archive are being returned in (apparently) the order that I entered the posts rather than in Published Date order.
The Archives read:
April 2007
May 2007
September 2007
August 2007
July 2007

Am I missing something or is there an XSL trick to order these lists by PublishedDate.

Nov 13, 2007 at 8:10 PM

Your MonthCount.xsl should contain...

<xsl:template match="/">
    <xsl:apply-templates select="rows/row[generate-id(.) = generate-id(key('months', substring(PublishedDate, 0, 8)))]">
        <xsl:sort select="PublishedDate" order="descending"/>

Nov 13, 2007 at 10:19 PM
You are the MAN!

What XSLT Book do you recommend? :)
Nov 13, 2007 at 10:28 PM
I don't read books...but Jeni Tennison does some good stuff
Nov 14, 2007 at 1:40 PM

How about "resources" for XSLT like the one above.
I am still struggling with the ordering on the Recent Posts. Since it grabs 5 records I need to sort them first, then grab 5. Does that take 2 template calls?

Nov 14, 2007 at 3:47 PM
I don't use any in particular resources myself, but there are lots of examples out there.

What control are you using for recent posts...what is the markup in the .master which is producing the XML?

Nov 14, 2007 at 4:57 PM
I started with the Motueka Theme:
<h3>Recent Posts</h3>
  <EBE:List ListName="Posts" runat="server" Transform-XslName="RecentPosts.xsl"/>

<xsl:stylesheet version="1.0" 
	xmlns:date="" xmlns:ebe="http://cks/ebemethods" 
	xmlns:xsl="" exclude-result-prefixes="date">
<xsl:param name="IsBlogOwner" />
<xsl:param name="RelativeUrl" />
<xsl:output omit-xml-declaration="yes" />
<xsl:template match="/">
  <xsl:variable name="endPos" select="count(rows/row)"/>
  <xsl:apply-templates select="rows/row[position() &gt; ($endPos)-5]">
    <xsl:sort select="PublishedDate" order="descending"/>
<xsl:template match="row">
    <a href="{ebe:createPostUrl(PublishedDate, BlogTitleForUrl)}"><xsl:value-of select="Title"/></a>

Nov 14, 2007 at 9:51 PM

Try changing your master page...

<h3>Recent Posts</h3>
     <EBE:SingleListQuery runat="server" Transform-XslName="Recent.xsl"
               ListName = "Posts" 
               ViewFieldsXML = "<FieldRef Name='Title'/><FieldRef Name='PublishedDate'/><FieldRef Name='BlogTitleForUrl'/>"
               QueryXML = "<OrderBy><FieldRef Name='PublishedDate' Ascending='FALSE'/></OrderBy>"/>


Nov 15, 2007 at 11:12 AM
Edited Nov 15, 2007 at 11:14 AM
That did it! (I just changed Ascending to TRUE.)

Is "SingleListQuery" doumented? If not can I help you with the documentation of features like this?

Check out
Nov 15, 2007 at 11:30 AM
Edited Nov 15, 2007 at 11:36 AM

Documentation is lacking, the closest thing to documentation for the SingleListQuery is...

However, there are other controls with interesting properties, AdditionalViewFields for example. We need to create a Wiki for the documentation, probably on the CKS codeplex site.

The blog looks great and thats a great article about using the EBE.


PS...I get name.dll errors when browsing the site you may want to modify the javascript file to remove this.
Nov 15, 2007 at 12:58 PM

PS...I get name.dll errors when browsing the site you may want to modify the javascript file to remove this.

Thanks, i have an override on the home page but I forgot the blog site. Try it again and let me know.

I'll check out the article.