How do I check for documents with more than 1 Tag in xwiki?

断了今生、忘了曾经 提交于 2019-12-24 09:41:37

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!