Blog Archives Macro
Last modified by Andreea Popescu on 2024/07/05 17:58
![]() | Views blogs published in the last X months |
Type | Doc (Velocity Macro) |
Category | |
Developed by | |
Rating | |
License | GNU Lesser General Public License 2.1 |
Table of contents
Description
#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
#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
Name | Optional | Allowed values | Default value | Description |
---|---|---|---|---|
$spaceApplicationBlog | no | a string | none | a space application blog |
$viewerBlogsResulting | no | a string | none | Viewer blogs resulting |
$nbrMonths | no | a int | none | Number of months to display |
Example
#BlogArchives("Space_MySpace_Blog" "Space_MySpaceCode.displayByDate" 7)