Livetable displaying pages with tag 1 OR tag 2 OR …

Hi,

I am trying to build a livetable which will display only pages that are tagged with a certain tag. But, given that different users will use similar but different tags, I would like to connect my conditions as “OR”.

Which means, if a page carries either tag “blue” OR tag “turquoise”, I would like them to show up.

I have been able to build a livetable that gives me pages with BOTH tags using

'extraParams' : '&tag=tag1&tag=tag2'

but that’s obviously not what I was going for.
Anyone there to help? Thanks a lot!

http://xwiki.475771.n2.nabble.com/Filter-a-livetable-tp7579401p7579421.html

I’m trying to do the same with 'extraParams': '&fieldName=value2&fieldName=value5'

AND is what I get - OR is what I’m searching for. The Link by @Rostyslav_Fitsyk is not available anymore.

You cannot do an OR by using the tag value in extraParams.

Technically, if you don’t specify a custom results page, the XWiki.LiveTableResults page is used (you can check it in your wiki). Internally this calls the XWiki.LiveTableResultsMacro page which contains some definition of velocity macros and especially the #gridresultwithfilter macro, which will end up calling this code, which says what to do if tag is specified:

As you can see this behavior is hardcoded.

What you could do is provide a custom results page.

Or, even better, is to move away from the now deprecated LiveTable to use LiveData: https://extensions.xwiki.org/xwiki/bin/view/Extension/Live%20Data%20Macro/

You can pass a configuration inside the livedata macro, see https://extensions.xwiki.org/xwiki/bin/view/Extension/Live%20Data%20Macro/#HParameters which points to https://extensions.xwiki.org/xwiki/bin/view/Extension/Live%20Data%20Macro/#HLiveDataJSON which should allow you to specify some filters.

Now, AFAIK, the filters only allow filtering on properties and not on tags (this BTW one of the last missing feature of LiveData to completely replace LiveTable).

Thus for @Julia LiveData is the solution but for @matt.kintsugi a custom results page for LiveTable is the solution.

So the LiveTable syntax

'extraParams': '&fieldName=value2&fieldName=value5'

has to be transformed to the LiveData syntax

filters='&fieldName=value2&fieldName=value5'

to get both entries.

Sure, but that’s not what you asked :slight_smile: You asked for an OR.

See ^^

1 Like

Now I’m a little confused. At my XWiki instance…
…the first line (LiveTable) is an AND
…the second line (LiveData) is an OR

'extraParams': '&fieldName=value2&fieldName=value5'

shows all entries with value2 AND value5 in their specific fieldName (only possible if it is a multi select value).

filters='&fieldName=value2&fieldName=value5'

shows all entries with value2 OR value5 in their specific fieldName (for a radio selected value). Of corse “value2 OR value5” means all entries with value2 AND all entries with value5.

The results of both lines are different and the second line does exactly what I was looking for :wink:

haha, that’s interesting and something new to me :slight_smile:

It would mean that we have a different behavior in LD and LT. BTW you’ve used the filters parameter. I think you can also use the extraParams parameter in the sourceParameters property since if you’ve used a livetable source for LD, the sourceParameters contains the LT parameters (something like sourceParameters="...extraParams=...).

cc @mflorea and @mleduc who have worked on the implementation of LD. I’m curious to know if it’s something wanted or not and if it was wanted, we need to document it on https://extensions.xwiki.org/xwiki/bin/view/Extension/Live%20Data%20Macro/

1 Like

So here’s a nice solution proposed by @MichaelHamann that allows to use an OR on tags with LD to list documents containing a XWiki.TagClass xobject:

{{liveData
  id="documents"
  properties="tags,doc.name"
  source="liveTable"
  filters="tags=a&tags=b"
  sourceParameters="className=XWiki.TagClass&translationPrefix=platform.index."
}}
  {
  "meta": {
    "propertyDescriptors": [
      {
        "id": "tags",
        "visible": false
      }
    ]
  }
}
{{/liveData}}

EDIT: Added to https://extensions.xwiki.org/xwiki/bin/view/Extension/Live%20Data%20Macro/#HExamples

1 Like