I have a xwiki project with a Tag system implemented. What I am trying to do is solve this problem. When I click on a Tag I get the correct output but I want to sort the documents according to their other Tags, which means I need a way to search by multiple tags. What I have done is get a list of documents tagged with the first tag then use #foreach
to look through each document for the Tags I need to show.
#set ($tag = "$!{request.get('tag')}")
#set ($list = $xwiki.tag.getDocumentsWithTag($tag))
#foreach($doc in $list)
#set ($tags = $xwiki.tag.getTagsFromDocuments($doc))
#foreach($tg in $tags)
#if($tg == 'Tutorial')
{{html}} #displayDocumentList($doc false $blacklistedSpaces){{/html}}
#end
#end
#end
The above code looks for documents that are tagged with $tag
and Tutorial
. Does not look very efficient but I am not looking for efficiency at this point of time, I just need it to work and the above code does not and I have no idea why.
EDIT::::
I tried a different solution. This time I get a $list
and $list2
where $list
are all the documents with the first tag and $list2
are the docs with the second tag. Then I compare each document's full name from one list to every document's full name in the second list. Still does not work. Here's the code,
#set ($tag = "$!{request.get('tag')}")
#set ($list = $xwiki.tag.getDocumentsWithTag($tag))
#set ($list2 = $xwiki.tag.getDocumentsWithTag('Tutorial'))
#foreach($doc in $list)
#foreach($doc2 in $list2)
#if($doc.fullName == $doc2.fullname)
$doc
#end
#end
#end
EDIT 2::::
So now the #foreach
loop gives me the correct output but my problem is I want to show the $doc as it would be shown if #{{html}} #displayDocumentList($doc false $blacklistedSpaces){{/html}}
was valid. Is not because I think the first params is supposed to be a list and here $doc is just one document.