Sorting the Recent Posts and Archives

Topics: Enhanced Blog Edition
Coordinator
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.

Matthew
Developer
Nov 13, 2007 at 8:10 PM
Matthew,

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"/>
    </xsl:apply-templates>
</xsl:template>

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

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

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?

Developer
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?

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

RecentPosts.xsl
<xsl:stylesheet version="1.0" 
	xmlns:date="http://exslt.org/dates-and-times" xmlns:ebe="http://cks/ebemethods" 
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 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:apply-templates>
</xsl:template>
 
<xsl:template match="row">
 <li>
    <a href="{ebe:createPostUrl(PublishedDate, BlogTitleForUrl)}"><xsl:value-of select="Title"/></a>
  </li>
</xsl:template>
</xsl:stylesheet>

HTH
Developer
Nov 14, 2007 at 9:51 PM
Matthew,

Try changing your master page...

 
<h3>Recent Posts</h3>
<ul>
     <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>"/>
</ul>

Vince

Coordinator
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 http://blogs.catapultsystems.com/matthew
Developer
Nov 15, 2007 at 11:30 AM
Edited Nov 15, 2007 at 11:36 AM
Matthew,

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

http://blog.thekid.me.uk/archive/2007/07/11/extend-your-cksebe-sharepoint-blog-with-no-code.aspx

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.

Vince

PS...I get name.dll errors when browsing the site you may want to modify the javascript file to remove this.
Coordinator
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.

Matthew