Live Table (or Live Data) listing child pages and also additional class properties

Hello,

im trying to make an Velocity script that uses Live Table or if possible Live Data, that lists all sub pages and also list their tags in a column if they have tags. If they don’t have tags they still should be listed. So far I am successful to create the Live Table that list all child pages with the columns that I need but I am failing to to figure out, how to read / display the tags of the pages.

What I tried so far is:

#set($collist = ['doc.title', 'tagsProperty.tags'])
#set($colprops = {
  'doc.title' : { 'type' : 'text' , 'size' : 30, 'link' : 'view', 'displayName' : 'Software' },
  'tagsProperty.tags' : { 'type' : 'text', 'displayName' : 'Tags' }
})
#set($options = { 
  "tagCloud" : true,
  "selectedColumn" : "doc.title",
  "rowCount" : 25,
  "extraParams" : "&tagsProperty=XWiki.TagClass",
  "extraParams" : "&location=Softwareliste"
})
#livetable('software' $collist $colprops $options)

The tagCloud is activated just for now to help me, I don’t want to use that later on.
In the column “Tags” every entry (even for pages that have at least one tag) shows “emptyvalue”. So im guessing im not correctly reading out the XWiki.TagClass.tags property of the pages.

As I understood it, "extraParams" : "&tagsProperty=XWiki.TagClass", defines a custom propertyName in my case “tagsProperty” so that it can be used in Live Table. “tagsProperty.tags” should (as I understood it) read out the “tags” property of the pages that have an Object from Type XWiki.TagClass.

As Live Tables are to be replaced by Live Data, I tried that too, but failed to even simply list all child pages of the current space. :frowning: That feature seems impressively powerful, but man this thing is huge.

Ok with Live Data I am able to create a Table that show the tags, BUT it now only list pages that have tags at all. Pages that don’t have tags are not shown.

{{liveData 
  filters="doc.location=Spielwiese" 
  limit="5" 
  properties="doc.title,tags,doc.location" 
  showPageSizeDropdown="false" 
  sort="doc.title:asc" 
  source="liveTable" 
  sourceParameters="className=XWiki.TagClass&translationPrefix=platform.index."}
}{{/liveData}}

However I wan’t to display all pages, even those that does not have tags.
Can you help me to achive that?

Also I want to filter to only show pages in that location, but I don’t want to include the collumn “doc.location”. If I remove “doc.location” from properties, then the filter wont apply. How do I hide the location column completely but still filter by it?

I know, when using Live Data users can unselect to see that doc.location property “accessible from the hamburger menu” but I don’t want it to be visible for users in the first place.

Hi! See below: "visible": false

{{liveData
  filters="doc.location=Software"
  limit="5"
  properties="doc.title,tags,doc.location"
  showPageSizeDropdown="false"
  sort="doc.title:asc"
  source="liveTable"
  sourceParameters="className=XWiki.TagClass&translationPrefix=platform.index."
  }}
  {
  "meta": {
    "propertyDescriptors": [
      {
        "id": "doc.location",
        "displayer": "html",
        "sortable": false,
        "filterable": false,
        "visible": false
      }
    ]
  }
}
{{/liveData}}

HTH!

1 Like

I think it is currently not possible. sourceParameters="className=XWiki.TagClass&translationPrefix=platform.index."} retrieves all documents, and only those documents holding at least one instance of class XWiki.TagClass. If a document has no XWiki.TagClass instance, it won’t appear. Workaround: add an XWiki.TagClass object with an empty tags property.

Looking for a better answer from developers and more experienced users! HTH!

1 Like

See below…

{{velocity}}
#set($collist = ['doc.title', 'tags'])
#set($colprops = {
  'doc.title' : { 'type' : 'text' , 'size' : 30, 'link' : 'view', 'displayName' : 'Software' },
  'tags' : { 'type' : 'text', 'displayName' : 'Tags' }
})
#set($options = { 
  "tagCloud" : true,
  "selectedColumn" : "doc.title",
  "rowCount" : 25,
  "extraParams" : "&tagsProperty=XWiki.TagClass",
  "extraParams" : "&location=Software"
})

#livetable('software' $collist $colprops $options)
{{/velocity}}

It is working for me here. In this case, documents not holding a XWiki.TagClass class instance will show Tags as emptyvalue. I don’t know why yet! Also, the parent page, Software.WebHome will appear in the list.

Just my two cents!

1 Like

Thank you very much, this is gold to me!

Is there an dynamic way to give Live Data velocity variables or other dynamic variables without using the new $services.liveData.render?

I wan’t to use something like {{liveData filters="doc.location=~"$doc" to filter and show only the current document and the children documents.

You can wrap the liveData macro in a velocity macro.

To reuse you example, this would look like:

{{velocity}}
{{liveData filters="doc.location=~"$doc"}}{{/liveData}}
{{/velocity}}
1 Like

Thank you, I had tried that initially but failed due to inline warning of the LiveData Macro and thought it was not usable like that. But now I fixed my mistake.

1 Like