Hello, If you want improve SpaceIndex macro, you can replace the code of this page ./bin/edit/Main/SpaceIndex?editor=object&classname=XWiki.WikiMacroClass by this one: Note: for previous version of 6.1 M2 (because Xwiki team has accepted my nice patch committed on github)
{{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 docName #set ($sort= $xcontext.macro.params.get('sort')) #if ("$sort"=='docName') ## sorting alphabetical list of document #set ($sort='doc.name asc') #elseif ("$sort"=='modificationDate') ## list of document sorting by update date #set ($sort='doc.contentUpdateDate desc') #else ## list of document sorting by creation date by default if creationDate value, no value, or wrong value is specified #set ($sort='doc.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 $sort").addFilter('currentlanguage').addFilter('hidden').setLimit($limit).bindValues([${spaceParam}]).execute()) {{html}} #displayDocumentList($docNamesfalse[]) ## 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}}
Hello,
If you want improve SpaceIndex macro, you can replace the code of this page
./bin/edit/Main/SpaceIndex?editor=object&classname=XWiki.WikiMacroClass by this one:
Note: for previous version of 6.1 M2 (because Xwiki team has accepted my nice patch committed on github)
## 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 docName
#set ($sort = $xcontext.macro.params.get('sort'))
#if ("$sort" == 'docName')
## sorting alphabetical list of document
#set ($sort = 'doc.name asc')
#elseif ("$sort" == 'modificationDate')
## list of document sorting by update date
#set ($sort = 'doc.contentUpdateDate desc')
#else
## list of document sorting by creation date by default if creationDate value, no value, or wrong value is specified
#set ($sort = 'doc.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 $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}}
Example:
{{spaceindex space="Sandbox" sort="docName" /}}
return the list of Sandbox space alphabeticaly ordering
It's done.
Would be even better if it avoided flattening space structure by only showing immediate children or indented sub-pages.