Hello everybody,
is it possible to perform a search query in the background within a confluence user macro?
I want to display the found results in a bullet list at the confluence page. I have found some classes within the confluence SDK but i dont know how to get them working within velocity.
Example classe which could perform a search:
Have you got any ideas?
Thanks in advance!
Michael
Instead of trying to mess with all that, why not just piggyback on top of one of the existing macros?
This should work for generating a CQL query:
## @noparams $action.getHelper().renderConfluenceMacro('{contentbylabel:showLabels=false|showSpace=false|cql=type = "page" and <rest of cql>}')
This displays more or less a bulleted list (with a page icon instead of bullets. If you want to modify the results, just assign the results to a variable and directly modify the text with the text manipulation methods available to velocity (for example, to not show anything when there are no results instead of the no labels found panel).
Hello Stephen,
thanks for your reply!
That´s a great idea and is working fine.
One problem: I am searching for a name which can be found within an attachment. Content By Label is returning then something like this:
"Page Link" > "Link to attachment"
I have tried with string functions to just return the "Page Link" but this is not working fine. I have tried .split() and substring in combination with indexOf without any success. With the .split() function i only get returned an address of the string object:
This is normally an array and i don´t know how to get the value within velocitiy not the object address...
Have you got any ideas?
Best Regards,
Michael
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Michael,
Actually, what you get returned is a list of strings. Unfortunately velocity (at least the version that is included in Confluence) doesn't have very good list functions, so you're pretty much limited to #foreach ($listItem in $list). Here is something fairly simple that should work:
## @noparams #set ( $htmlString = $action.getHelper().renderConfluenceMacro('{contentbylabel:showLabels=false|showSpace=false|cql=type = "attachment"}') ) <ul> #foreach ( $htmlTag in $htmlString.split(' <') ) #set ( $htmlTag = '<' + $htmlTag ) #if ( $htmlTag.contains('/download/attachments/') ) <li>$htmlTag</li>
#end #end </ul>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Stephen,
thanks that´s exactly what i needed!
Thank you very much!
Best Regards,
Michael
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.