On 08/11/2011 11:03 AM, 许凌志(Jamesxu) wrote:
On Thu, Aug 11, 2011 at 1:03 AM, Sergiu Dumitriu<[email protected]> wrote:
Looks like you have quotes inside quotes, which is syntactically incorrect. You can either use double quotes for the outside:
"where doc.space='Main' order by doc.date desc"
or double the single quotes inside:
'where doc.space=''Main'' order by doc.date desc'
I have tried both, but all failed, the error infomation is bellow: Failed to execute the [velocity] macroorg.xwiki.rendering.macro.MacroExecutionException: Failed to evaluate Velocity Macro for content [#set($media = "$!request.media") #set($nb = "$!request.nb") #if($nb != '') #set($nb = $util.parseInt($nb) + 1) #else #set($nb = 5) #end
#if ($media == 'json') #set($discard = $response.setContentType("application/json")) #set ($recentlyModifiedPage = $xwiki.searchDocuments('where where doc.space=''Main'' order by doc.date desc order by doc.date desc', $nb, 0))
^ You have twice "order by doc.date desc" in the query.
#set($size = $recentlyModifiedPage.size()) [ #foreach ($docname in $recentlyModifiedPage) #if ($xwiki.hasAccessLevel('view', $xcontext.getUser(), $docname)) #set ($rdoc = $xwiki.getDocument($docname)) #set($name = $rdoc.getName()) #set($fullname = "$rdoc.getWiki():$rdoc.getSpace().$rdoc.getName()") {"info":"${escapetool.javascript($rdoc.fullName)}", "path":"${escapetool.javascript($fullname)}", "name":"$name", "type":"wikipage"} #if($velocityCount< $size) , #end #end #end
-- Sergiu Dumitriu http://purl.org/net/sergiu/