BrianJones wrote:
Hello,
This is just a quick question regarding the functionality of tags, and
searching by tags.
Currently, when you go to the 'Tags' page, where a list of all tags being
used is displayed, when you click on one of the tags, it transfers you to a
page containing a table of all the pages that are using this tag, with some
other information.
My question is regarding how, or if it is at all possible to utilize this
search functionality with multiple tags. For instance, instead of just
searching for tag 'abc', to be able to search for all documents that contain
two tags, 'abc, and 'def'.
I know in confluence this is possibly simply by selecting another tag, or
appending the tag name with a '+' in the address bar (.../tag_a+tag_b).
Can anyone provide me with a bit of information regarding this? Thanks very
much to the community.
Cheers
#set($tagFilter = "")
#foreach($requestedTag in $request.getParameterValues('tag'))
#set($tagFilter = "${tagFilter} and '${requestedTag}' in
elements(prop.list)")
#end
#set($sql = ", BaseObject as obj, DBStringListProperty as prop where
obj.name=doc.fullName and obj.className='XWiki.TagClass' and
obj.id=prop.id.id and prop.id.name='tags' ${tagFilter} order by doc.name
asc")
#set ($list = $xwiki.searchDocuments($sql))
Now, just use several tag=value request parameters, as in:
?tag=tag1&tag=tag2
--
Sergiu Dumitriu
http://purl.org/net/sergiu/