0

I use xwiki to create a wiki. I want to dynamicaly display a list of pages (in a livetable or just bulk.), so I use the tag system.

Currently I use the HTML macro + iframe but it display all the page with header, side menus, options, etc.

I've tried this snippet but nothing is displaying and I don't really understand all the code, I'm not sure that is the good solution.

I've tried to use Display and Include macros :

{{display reference="Main.Tags"/}}

It display all my tags in a cloud.

But to had what I want I should specify this code with

queryString="do=viewTag&tag=Test"

Or something like that but I don't know how to do it.

So if you have an idea to display the list of pages with the same tag I will be happy to read it :)

Thanks.

EDIT1

So I work on it and I display what i want with the following instruction :

    {{velocity}}
#set ($list = $xwiki.tag.getDocumentsWithTag('test'))
#foreach($doc in $list)
  $doc
#end
{{/velocity}}

But the problem is that display all the path of the document.

    Wiki Interne.2\. Liste des flux TEST.2_1_Flux_Externes_Entrants.AGDAT01.WebHome
Wiki Interne.2\. Liste des flux TEST.2_1_Flux_Externes_Entrants.AGOL20.WebHome
Wiki Interne.2\. Liste des flux TEST.2_1_Flux_Externes_Entrants.AGOL21.WebHome
Wiki Interne.2\. Liste des flux TEST.2_1_Flux_Externes_Entrants.AGOL22.WebHome

How can I restrict the display only to the title of the document?

3 Answers 3

0

You can use the Livetable macro (http://extensions.xwiki.org/xwiki/bin/view/Extension/Livetable%20Macro) to list the pages you want and customize it to only show the pages tagged with a specific tag.

{{velocity}}
#set($collist = ['doc.title', 'doc.location', 'doc.date', 'doc.author'])
#set($colprops = {
 'doc.title' : { 'size' : 30, 'link' : 'view', 'filterable': false, 'sortable': false },
 'doc.location' : { 'html' : true },
 'doc.date' : { 'type' : 'date' },
 'doc.author' : { 'type' : 'text', 'link' : 'author' }
})
#set($options = {
 'translationPrefix' : 'platform.index.',
 'rowCount' : 15,
 'tagCloud' : 'true',
 'selectedTags' : ['test']
})
#if(!$isGuest)
 #set($discard = $collist.add('_actions'))
 #set($discard = $colprops.put('_actions', { 'actions' : ['copy', 'delete', 'rename', 'rights'] }))
#end
#livetable('taggedDocs' $collist $colprops $options)
{{/velocity}}

Since the 'tagCloud' option needs to be enabled in order for the 'selectedTags' option to allow you to list the tags you want to show by default (in my example, I am listing pages tagged with the tag 'test'), you will also see all the other available tags that the user could select from. If that bothers you and you want to not allow the user to change the displayed tag, you could simply hide the 'tagCloud' section above the livetable by going in object edit mode on the page and adding an object of type 'StyleSheetExtension' (see http://www.xwiki.org/xwiki/bin/view/Documentation/DevGuide/Tutorials/SkinExtensionsTutorial/#HMinimalStyleSheeteXtension for more details) with the following CSS content:

#alldocs-tagcloud {
  display : none;
}
0
0

Thanks @Eduard Moraru :) I will try it.

However I've resolved my case when I found the Velocity doc : http://velocity.apache.org/engine/1.7/user-guide.html

The code for people who might be interested :

{{velocity}}
#set ($list = $xwiki.tag.getDocumentsWithTag('Your Tag'))
         #foreach($reference in $list)
  #set ($document = $xwiki.getDocument($reference))
  #set ($label = $document.getTitle())
         [[$label>>$reference]]
   #end
{{/velocity}}
0

Try this, it is shameless cut fron build-in tag app.

{{velocity}}
#set ($tag='Tag')
  #if ("$!{request.get('renamedTag')}" != '')
    {{info}}$services.localization.render('xe.tag.rename.success', ["//${request.get('renamedTag')}//"]){{/info}}

  #end
  #set ($list = $xwiki.tag.getDocumentsWithTag($tag))
  {{container layoutStyle="columns"}}
    (((
      (% class="xapp" %)
      === $services.localization.render('xe.tag.alldocs', ["//${tag}//"]) ===

      #if ($list.size()> 0)
        {{html}}#displayDocumentList($list false $blacklistedSpaces){{/html}}
      #else
        (% class='noitems' %)$services.localization.render('xe.tag.notags')
      #end
    )))
  {{/container}}
#set ($displayDocExtra = false)
{{/velocity}}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.