Details
-
Improvement
-
Resolution: Fixed
-
Major
-
6.0
-
None
-
Debian Wheezy, Tomcat 7.0.47
Description
Hello,
It would be nice to improve SpaceIndex macro with adding some sorting parameter.
Could you replace the code of this page
./bin/edit/Main/SpaceIndex?editor=object&classname=XWiki.WikiMacroClass by this one?
{{velocity}}
## TODO: add me a parameter to specify the style, list or livetable
## get the number of documents to display
#set ($limit = $xcontext.macro.params.get('count'))
#if ("$!limit" == '')
## 100 documents displayed by default if no value is specified
#set ($limit = '100')
#end
#set ($limit = $mathtool.toInteger($limit))
## get the sort of the list of document
##values are creationDate, modificationDate and name
#set ($sort = $xcontext.macro.params.get('sort'))
#if ("$sort" == 'name')
## sorting alphabetical list of document
#set ($sort = 'name asc')
#elseif ("$sort" == 'modificationDate')
## list of document sorting by update date
#set ($sort = 'contentUpdateDate desc')
#else
## list of document sorting by creation date by default if creationDate value, no value, or wrong value is specified
#set ($sort = 'creationDate desc')
#end
## get the space to display the documents for
#set ($spaceParam = $doc.space)
#set ($spaceMacroParam = $xcontext.macro.params.get('space'))
#if ("$!spaceMacroParam" != '')
#set ($spaceParam = $spaceMacroParam)
#end
#set ($docNames = $services.query.hql("where doc.space=? order by doc.$sort ").addFilter('currentlanguage').addFilter('hidden').setLimit($limit).bindValues([${spaceParam}]).execute())
{{html}}
#displayDocumentList($docNames false [])
## Note: we pass an empty blacklistedSpaces list since we are used as a space dashboard, not a global dashboard
{{/html}}
#if ($docNames.size() == $limit)
#set ($docCount = $services.query.xwql('where doc.space = :space').bindValue('space', $spaceParam).addFilter('unique').count())
#set ($remaining = $mathtool.sub($docCount, $limit))
#if ($remaining > 0)
(% class="documentListMore" %) (((
// $services.localization.render('xe.dashboard.space.remainingDocumentsInSpace', [$remaining, $spaceParam])
[[$services.localization.render('xe.dashboard.space.visitSpaceIndex')>>Main.SpaceIndex?space=${escapetool.url($spaceParam)}]] //
)))
#end
#end
##
## Document creation.
##
## Only if the current user has edit rights.
#if ($hasCreatePage)
{{html}}
<ul class="xlist">
<li class="page create"><a href="$doc.getURL('create')">$services.localization.render('platform.index.spaceIndexDocumentListCreate')</a></li>
</ul>
{{/html}}
#end
{{/velocity}}
I add the sort order parameter:
Name: sort
Optional: yes
Allowed values: creationDate, modificationDate and name
Default value: creationDate
Description: creationDate sorting the list by creation date of documents, modificationDate by update date and name sorting alphabeticaly the list
Example:
spaceindex space="Sandbox" sort="name" /
return the list of Sandbox space alphabeticaly ordering
Thxs
Pascal B.
Attachments
Issue Links
- relates to
-
XWIKI-11356 Add translation keys for the sort-parameter of the spaceindex macro
-
- Closed
-