问题
So I want to access all the documents that are tagged using 2 tags instead of one. For example I want all photoshop tutorial documents.If I searched with the tag tutorial I would get other software tutorials too and if I use the tag photoshop i get all documents and not just the tutorials. I should be able to provide 2 tags and get documents which are tagged with both these tags.
Right now this is what I did,
#set ($list = $wiki.tag.getDocuments($tag))
#set ($list2 = $list.getDocuments($tag2))
Needless to say it does not work. My next attempt was
#set($list = $wiki.tag.getDocuments($tag $tag2))
I guess if I could modify the getDocuments()
method I would be able to achieve this but I can't seem to locate it.
回答1:
NOTE: This answer is given to me by Vincent Massol (a committer on the XWiki project), but he's unable to answer with his StackOverflow account.
You can use the following XWQL query which will list all documents having tags "tag1" and "tag2":
{{velocity}}
$services.query.xwql("from doc.object(XWiki.TagClass) as tag where 'tag1' member of tag.tags and 'tag2' member of tag.tags").execute()
{{/velocity}}
For more information on how to use XWQL see the reference documentation at http://extensions.xwiki.org/xwiki/bin/view/Extension/Query+Module
来源:https://stackoverflow.com/questions/18394365/how-do-i-check-for-documents-with-more-than-1-tag-in-xwiki