I am trying to use SortTool from Velocity Generic Tools inside a decorator that handles the search results.
The code is:
<div id="search-results-body"> <ul class="search-results"> #foreach($searchResult in $sorter.sort($results, "lastModificationDate:desc")) <li > $action.newSearchResult($searchResult, $showExcerpts, $queryString) </li> #end </ul> </div>
Where $results is the collection of search results and $sorter is a handle to the Sorter class as explained in SortTool.
But the foreach loop is not executed since nothing is displayed, this is because $sort is null which means that confluence default velocity context don't know about that class.
How can I use those generic tools inside the decorators?
Thank you.
I found a solution in case someone need it:
1) install velocity-tools-generic-2.0.jar in confluence/WEB-INF/lib
2) Create a plugin in order to add $sorter to Confluence velocity context:
<atlassian-plugin name="Sorter" key="confluence.extra.sorter"> <plugin-info> <description> Plugin to do sorts in velocity templates and decorators. </description> <!-- This version is displayed in the application's Plugin Manager. --> <version>1.0</version> </plugin-info> <velocity-context-item key="mySorter" name="Sorter" context-key="sorter" class="org.apache.velocity.tools.generic.SortTool" /> </atlassian-plugin>
Now the search results are ordered descending. I would like to know if there is a cleaner way to do 2), since just doing 1) didn't do, nothing was shown.
Can't get sorttool class to load, please help.
Could not load class: org.apache.velocity.tools.generic.SortTool' to 'com.leonizm.confluence.plugins.testp'
Thanks,
Leon
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am summing: To use $sorter.sort($results,"lastModificationDate:desc"
))
in velocity macros
Confluense Admin->User Macros macros in confluense
You should
1) install velocity-tools-generic-2.0.jar in confluence/WEB-INF/lib
2) Name xml above as "atlassian-plugin.xml" zip (the only file) it into .jar file (for example sorter.jar) and install it as a usual plugin using Confluense Admin->Plugins .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Awesome, thanks for this!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Andrey.sorter.jar was working fine with confluence 4.3.Do I need to make changes in order to use the same jar in 5.6.5.After installation of sorter.jar in 5.6.5 it shows an error "This add-on could not be loaded. It has one or more errors that prevent it from being enabled. Refer to the logs for more information.". Can you please help regarding this.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.