【问题标题】:How to display list of pages related to a tag in xwiki如何在 xwiki 中显示与标签相关的页面列表
【发布时间】:2018-02-07 16:33:41
【问题描述】:

我使用 xwiki 创建一个 wiki。我想动态显示页面列表(在 livetable 中或只是批量。),所以我使用标签系统。

目前我使用 HTML 宏 + iframe,但它会显示带有标题、侧边菜单、选项等的所有页面。

我尝试了this snippet,但没有显示任何内容,而且我并不真正理解所有代码,我不确定这是一个好的解决方案。

我尝试使用显示和包含宏:

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

它将我所有的标签显示在云端。

但要获得我想要的,我应该指定此代码

queryString="do=viewTag&tag=Test"

或类似的东西,但我不知道该怎么做。

因此,如果您有想法显示具有相同标签的页面列表,我将很乐意阅读它:)

谢谢。

编辑1

所以我开始工作,并按照以下说明显示我想要的内容:

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

但问题是显示文档的所有路径。

    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

如何限制只显示文档的标题?

【问题讨论】:

    标签: javascript macros tags xwiki


    【解决方案1】:

    您可以使用 Livetable 宏 (http://extensions.xwiki.org/xwiki/bin/view/Extension/Livetable%20Macro) 列出您想要的页面并将其自定义为仅显示带有特定标记的页面。

    {{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}}
    

    因为需要启用 'tagCloud' 选项才能让 'selectedTags' 选项允许您列出默认情况下要显示的标签(在我的示例中,我列出了带有标签 'test' 的页面),您还将看到用户可以从中选择的所有其他可用标签。如果这让您感到困扰并且您不想让用户更改显示的标签,您可以通过进入页面上的对象编辑模式并添加类型为“StyleSheetExtension”的对象来简单地隐藏 livetable 上方的“tagCloud”部分(请参阅http://www.xwiki.org/xwiki/bin/view/Documentation/DevGuide/Tutorials/SkinExtensionsTutorial/#HMinimalStyleSheeteXtension 了解更多详细信息)具有以下 CSS 内容:

    #alldocs-tagcloud {
      display : none;
    }
    

    【讨论】:

      【解决方案2】:

      谢谢@Eduard Moraru :) 我会试试的。

      但是,当我找到 Velocity 文档时,我已经解决了我的问题:http://velocity.apache.org/engine/1.7/user-guide.html

      可能感兴趣的人的代码:

      {{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}}
      

      【讨论】:

        【解决方案3】:

        试试这个,它是无耻的内置标签应用程序。

        {{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}}
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2015-09-08
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2022-10-12
          • 2013-08-28
          相关资源
          最近更新 更多