Version 19.1 by Jerome on 2010/12/06 12:59
Warning: For security reasons, the document is displayed in restricted mode as it is not the current version. There may be differences and errors due to this.

cog
TypeDoc (Velocity Macro)
Category
Developed byUnknown
Rating
0 Votes
LicenseUnknown

Description

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

Failed to execute the [velocity] macro. Cause: [Nested scripts are not allowed. Current Script Macro [velocity] (source [extensions:ExtensionCode.ExtensionSheet]) is executed inside Script Macro [velocity] (source [extensions:ExtensionCode.ExtensionSheet])]. Click on this message for details.

Example

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

Result

Exemple.JPG

Get Connected