Parentschildrenlivetable displays nothing

Maybe the document macro?

https://extensions.xwiki.org/xwiki/bin/view/Extension/Documents%20Macro

That looks like an option, don’t understand why it doesn’t show as a choice in the WYSIWYG editor macro list…

But still need advice. If I just include that, I get a list of all pages. Is there some idiom to tell it “children of the current page?” It looks like it needs a “location” parameter, but not sure what to put for that.

I guess setting the parent= option to the index page’s path + .WebHome works. I had hoped there was some simple way to reference the page containing the macro instead of having to specifically call out the page name/path.

OK, I see what I missed in the macro document. Wish it were a little easier for users to do this, but guess it’s a teaching opportunity.

Thanks for the reference to the documents macro.
-Alan

Well, wait. I just tried this on a page in our wiki instead of the {{children} macro. The children macro showed 32 documents. The {{documents}} macro only listed 13 pages. Makes no sense but the {{documents}} macro misses a lot of children…

The pages are listed in the children viewer of the page, and I can’t see any reason the macro wouldn’t see them. Is this a bug?

Used the code:

{{velocity}}
{{documents actions=false count=20 columns="doc.title,doc.date,doc.author" parent="$doc.fullName"}}{{/documents}}
{{/velocity}}

No but you need to read the doc carefully.

See https://extensions.xwiki.org/xwiki/bin/view/Extension/Documents%20Macro#HUsage

For example:

  • parent (optional and deprecated): If specified, only list pages having the specified parent (by default all documents are listed). Doesn’t work with Nested Pages, use the location parameter instead.

Yet you’ve used it in your example and since you have nested pages, it didn’t work of course :slight_smile:

Which begs the question then… what DOES work in such a context (nested pages)? Or alternatively, how do I set up a context in which something would work?

I’d really love to improve the doc but how can it be more explicit than:

Doesn’t work with Nested Pages, use the location parameter instead.

?

There’s even an example on that page…

I keep looking at that page, looking for an example of a location= parameter that shows how to reference the parent, or to at least filter the pages that are children of the current page. The one example seems to filter pages that have “Draft” in the path. All the other examples are deprecated.

So back to a question I asked several cycles back… what would the location= parameter look like to say “children of this page”?

I mean, I really am looking at the document, but I just don’t see an answer to that.

You can’t really say “children of the page” but you can see pages having this part in their reference.

Let’s say your pages are inside a page named “Page1”, so their full references are “Page1.PageN.PageP”.

You would use location="Page1.".

Of course, and that’s the limit of this, if you have another reference named SomeOtherPage.Page1.Whatever then you’d also get that to match so you need to find a pattern that matches only what you need.

There’s currently no real support of exact children pages in this {{documents}} macro.

Only thing missing is a way to indicate the start of the reference with something like location="^Page1." which would indicate the start of the reference.

Or a startsWith parameter such as startsWith="Page1.".

FTR I’ve found the jira issue about this: https://jira.xwiki.org/browse/XWIKI-13652

The problem with location=, in addition to to the reference match issue you mention, is what you might mean by “exact children”… if I use the location pattern to match the parent page path, the resulting page list includes the parent page too. I wanted only the children, not children+parent.

I’ve commented at https://jira.xwiki.org/browse/XWIKI-13652?focusedCommentId=102004&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-102004

Note that a very simple workaround FTM could be to use the following content in the page for which you wish to display its children:

{{template name="children.vm"/}}

And if you need customizations you could copy the children.vm content into the page or into a new wiki macro…

{{velocity}}
{{html}}
#set ($collist = ['doc.title', 'doc.location', 'doc.date', 'doc.author', '_actions'])
#set ($colprops = {
  'doc.title'    : { 'link' : 'view' },
  'doc.author'   : { 'link' : 'author', 'type': 'text', 'filterable': true},
  'doc.location' : { 'type': 'text', 'filterable': true, 'html': true},
  '_actions'     : { 'actions': ['copy', 'rename', 'rights', 'delete'] }
})
#set ($urlParameters = "xpage=getdocuments&childrenOf=$escapetool.url($doc.space)&queryFilters='unique'")
#set ($options = {
  'url' : "$doc.getURL('get', $urlParameters)",
  'selectedColumn' : 'doc.location',
  'translationPrefix' : 'platform.index.',
  'outputOnlyHtml' : true
})
#livetable('childrenIndex' $collist $colprops $options)
{{/html}}
{{/velocity}}

EDIT: I took the content of children.vm and make it minimal for you in the pasted code above.

1 Like

Thanks. Tried the {{template}} idea, but it created a messy copy of the children viewer page inside the page, looked really bad.

The other idea with the velocity macro is much better, except it includes a “page administration” (WebPreferences) entry in the list as well as the children. Must be something funny with the query…

Got it to work. Needed the ‘hidden’ parameter in there.
Was able to create a global macro to do what I needed.
Thanks for the hints.

Hello @vmassol :slight_smile: how to ignore hidden pages ?

I tried this but doesn’t work (WebPreference page are displayed)

{{velocity}}
{{html}}
#set ($collist = ['doc.title', 'doc.location', 'doc.date', 'doc.author', '_actions'])
#set ($colprops = {
  'doc.title'    : { 'link' : 'view' },
  'doc.author'   : { 'link' : 'author', 'type': 'text', 'filterable': true},
  'doc.location' : { 'type': 'text', 'filterable': true, 'html': true},
  '_actions'     : { 'actions': ['copy', 'rename', 'rights', 'delete'] }
})
#set ($urlParameters = "xpage=getdocuments&childrenOf=$escapetool.url('MyWiki.Section1.Category1')&queryFilters='unique'&queryFilters='hidden'")
#set ($options = {
  'url' : "$doc.getURL('get', $urlParameters)",
  'selectedColumn' : 'doc.location',
  'translationPrefix' : 'platform.index.',
  'outputOnlyHtml' : true
})
#livetable('childrenIndex' $collist $colprops $options)
{{/html}}
{{/velocity}}

This code works but I can’t specify specific page, it take current page :

{{velocity}}
## Source : https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-templates/src/main/resources/templates/children.vm
{{html wiki='true'}}  

  
    ##
    ## List the children documents using a livetable
    ##
    #set ($queryFilters = 'unique,hidden')    
    ## Sets allowProperty to the empty value for the copy action to preserve the livetable behavior where an action with an
    ## undefined rights was implicitly allowed as long as it was not an admin action (admin, rename, or rights).
    
    #set ($sourceParameters = $escapetool.url({
      'template' : 'getdocuments.vm',
      'translationPrefix' : 'platform.index.',
      'queryFilters': $queryFilters,
      '$doc': 'MyWiki.Section1.Category1'
    }))
    {{liveData
      id='childrenIndex'
      source='liveTable'
      sourceParameters="$sourceParameters"
      properties='doc.title,doc.location,doc.date,doc.author,_actions'
      sort='doc.location:asc'
      }}{{/liveData}}
  
{{/html}}
{{/velocity}}

How to specify page ?