BlogArchives Macro

This is a Velocity macro, which isn't bundled with any XWiki product by default.
Macro contributed by Djebloun Sidali.
This macro cannot currently be downloaded separately.

BlogArchives Macro

Viewing blogs published in the last x months

This is for the old blog application that was bundled with the default XWiki Enterprise XAR. We now have a new Blog Application that is offering such a macro in addition to an already made Panel too.

#macro(BlogArchives $spaceApplicationBlog $viewerBlogsResulting $nbrMonths) 

#set($months = ["Foo","Janvier","Février","Mars","Avril","Mai","Juin","Juillet","Août","Septembre","Octobre","Novembre","Décembre"]) #set($results=$xwiki.search("select year(doc.creationDate), month(doc.creationDate), count(doc) from XWikiDocument doc, BaseObject as obj where obj.name=doc.fullName and doc.web='$spaceApplicationBlog' and obj.className='XWiki.ArticleClass' group by month(doc.creationDate) order by year(doc.creationDate) desc",$nbrMonths,0)) #set($docYear=".") #foreach ($row in $results) #foreach ($col in $row) #if ($velocityCount==1 && $docYear!=$col) #set($docYear=$col) * $docYear #elseif ($velocityCount==2) #set($docMonth=$col) #elseif ($velocityCount==3) #set($count=$col) #end #end ** <a href='$xwiki.getURL("$viewerBlogsResulting","view","curDate=${docMonth}-${docYear}")'>$months.get($docMonth) ($count)</a> #end

#end

Usage

#BlogArchives($spaceApplicationBlog $viewerBlogsResulting $nbrMonths)

Parameters definition

NameOptionalAllowed valuesDefault valueDescription
$spaceApplicationBlognoa stringnonea space application blog
$viewerBlogsResultingnoa stringnoneViewer blogs resulting
$nbrMonthsnoa intnoneNumber of months to display

Example

#BlogArchives("Space_MySpace_Blog" "Space_MySpaceCode.displayByDate" 7)

Result

Exemple.JPG

Tags:
Created by Djebloun Sidali on 2009/02/10 09:30
Last modified by Djebloun Sidali on 2009/02/10 14:01

This wiki is licensed under a Creative Commons license
2.2.1.27354