Changes for page Blog Archive Panel
on 2026/12/02 07:30
on 2026/11/28 07:59
Summary
Details
- Page properties
-
- Author
-
... ... @@ -1,1 +1,1 @@ 1 -XWiki. superadmin1 +XWiki.Admin
- Panels.PanelClass[0]
-
- Content
-
... ... @@ -1,64 +1,43 @@ 1 -{{include reference="Blog.BlogCode"/}} 2 - 3 -{{velocity}} 4 -#getAllBlogPostsQueryBasedOnDisplayContext($doc $query $queryParams) 5 -#set ($discard = $queryParams.put('creator', $xcontext.user)) 6 -#set ($query = "$!{query} and (doc.creator = :creator or (isPublished.value = 1 and hidden.value = 0))") 7 -#set ($queryObj = $services.query.hql($query).addFilter('unique')) 8 -#bindQueryParameters($queryObj $queryParams) 9 -#set ($displayArchivePanel = false) 10 -#if ($queryObj.count() > 0 || $showEmptyPanels) 11 - #set ($displayArchivePanel = true) 1 +#includeMacros("Blog.BlogCode") 2 +#set($space = "$!{request.space}") 3 +#if($space == '') 4 + #set($space = $doc.space) 12 12 #end 13 -#if ($displayArchivePanel) 14 - #if ($isCategoryPage || $isCategoriesHomePage) 15 - #set ($archivePage = $doc.fullName) 16 - #else 17 - #getBlogDocument($doc.space $blogDoc) 18 - #set ($archivePage = $blogDoc.fullName) 19 - #end 20 - #panelheader($services.localization.render('blog.archive.paneltitle')) 6 +#getBlogDocument($space $blogDoc) 7 +#if($space == $blogDoc.space || $showEmptyPanels) 8 + #panelheader("Blog Archive") 9 + #getBlogEntriesBaseQuery($query) 10 + #set($query = "${query} and (doc.space = '${blogDoc.space}' or doc.parent = '${blogDoc.fullName}')") 21 21 ## Create a Jodatime date formatter that will be used to format dates 22 - #set ($monthFormatter = $xwiki.jodatime.getDateTimeFormatterForPattern('MMMM')) 23 - #set ($tempDate = $xwiki.jodatime.mutableDateTime) 24 - #set ($currentYear = $xwiki.formatDate($datetool.date, 'yyyy')) 25 - #set ($currentMonth = $xwiki.formatDate($datetool.date, 'M')) 26 - #set ($firstYear = '') 27 - #set ($lastYear = '') 28 - #set ($firstYearQueryObj = $services.query.hql("${query} order by year(publishDate.value)").setLimit(1).addFilter('unique')) 29 - #bindQueryParameters($firstYearQueryObj $queryParams) 30 - #foreach ($firstEntry in $firstYearQueryObj.execute()) 31 - #set ($discard = $xwiki.getDocument($firstEntry)) 12 + #set($monthFormatter = $xwiki.jodatime.getDateTimeFormatterForPattern("MMMM")) 13 + #set($tempDate = $xwiki.jodatime.mutableDateTime) 14 + #set($currentYear = $xwiki.formatDate($util.date, 'yyyy')) 15 + #set($currentMonth = $xwiki.formatDate($util.date, 'M')) 16 + #set($firstYear = '') 17 + #set($lastYear = '') 18 + #foreach($firstEntry in $xwiki.searchDocuments("${query} order by year(publishDate.value)", 1, 0)) 19 + #set($discard = $xwiki.getDocument($firstEntry)) 32 32 #getEntryObject($discard $entryObj) 33 33 #getEntryDate($discard $entryObj $firstYear) 34 - #set ($firstYear = $numbertool.toNumber($xwiki.formatDate($firstYear,'yyyy')).intValue())22 + #set($firstYear = $util.parseInt($xwiki.formatDate($firstYear, "yyyy"))) 35 35 #end 36 - #set ($lastYearQueryObj = $services.query.hql("${query} order by year(publishDate.value) desc").setLimit(1).addFilter('unique')) 37 - #bindQueryParameters($lastYearQueryObj $queryParams) 38 - #foreach ($lastEntry in $lastYearQueryObj.execute()) 39 - #set ($discard = $xwiki.getDocument($lastEntry)) 24 + #foreach($lastEntry in $xwiki.searchDocuments("${query} order by year(publishDate.value) desc", 1, 0)) 25 + #set($discard = $xwiki.getDocument($lastEntry)) 40 40 #getEntryObject($discard $entryObj) 41 41 #getEntryDate($discard $entryObj $lastYear) 42 - #set ($lastYear = $numbertool.toNumber($xwiki.formatDate($lastYear,'yyyy')).intValue())28 + #set($lastYear = $util.parseInt($xwiki.formatDate($lastYear, "yyyy"))) 43 43 #end 44 - #if ("$!{firstYear}" != '') ## At least one entry exists 45 - #foreach ($year in [$firstYear..$lastYear]) 46 - #set ($yearArticleCountQueryObj = $services.query.hql("${query} and year(publishDate.value) = $year").addFilter('unique')) 47 - #bindQueryParameters($yearArticleCountQueryObj $queryParams) 48 - #set ($yearArticleCount = $yearArticleCountQueryObj.count()) 49 - #if ($yearArticleCount > 0) 50 - #set ($queryString = "sheet=Blog.ArchiveSheet&year=${year}") 51 - * [[$year (% class="itemCount" %)(${yearArticleCount})(%%)>>${archivePage}||queryString="${queryString}"]] 52 - #if ($year == $currentYear) 53 - #foreach ($month in [1..12]) 54 - #set ($statement = "${query} and year(publishDate.value) = $year and month(publishDate.value) = $month") 55 - #set ($monthArticleCountQueryObj = $services.query.hql($statement).addFilter("unique")) 56 - #bindQueryParameters($monthArticleCountQueryObj $queryParams) 57 - #set ($monthArticleCount = $monthArticleCountQueryObj.count()) 58 - #if ($monthArticleCount > 0) 59 - $tempDate.setMonthOfYear($month)## 60 - #set($queryString = "sheet=Blog.ArchiveSheet&year=${year}&month=${month}") 61 - ** [[$monthFormatter.print($tempDate) (% class="itemCount" %)(${monthArticleCount})(%%)>>${archivePage}||queryString="${queryString}"]] 30 + #if("$!{firstYear}" != '') ## At least one entry exists 31 + #foreach($year in [$firstYear..$lastYear]) 32 + #set($yearArticleCount = $xwiki.countDocuments("${query} and year(publishDate.value) = $year")) 33 + #if($yearArticleCount > 0) 34 + * <a href="$xwiki.getURL('Blog.Archive', 'view', "space=${blogDoc.space}&year=${year}")">$year ($yearArticleCount)</a> 35 + #if($year == $currentYear) 36 + #foreach($month in [1..12]) 37 + #set($monthArticleCount = $xwiki.countDocuments("${query} and year(publishDate.value) = $year and month(publishDate.value) = $month")) 38 + #if($monthArticleCount > 0) 39 + $tempDate.setMonthOfYear($month) 40 + ** <a href="$xwiki.getURL('Blog.Archive', 'view', "space=${blogDoc.space}&year=${year}&month=${month}")">$monthFormatter.print($tempDate) (${monthArticleCount})</a> 62 62 #end 63 63 #end 64 64 #end ... ... @@ -65,8 +65,7 @@ 65 65 #end 66 66 #end 67 67 #else 68 - {{info}}{{translation key="blog.archive.noarticle"/}}{{/info}}47 + #info("No articles yet...") 69 69 #end 70 70 #panelfooter() 71 71 #end 72 -{{/velocity}}