Is it possible to list pages with a short annotation using a macro or script?

I would like to display a list of child pages.
so that small annotations about these pages are additionally displayed. For example, specially filled text in a field or the first 100 characters. Is there some method for doing this?

Yes this is quite easy to do with scripting. You need to start defining where you find that metadata about each page. One way is to create an XClass and add an xobject to each page containing the info you wish.

Then you can use a XWQL Query to find nested pages having such an xobject, see https://extensions.xwiki.org/xwiki/bin/view/Extension/Query%20Module

1 Like

Thanks, I’ll try to do it tomorrow

Thank you! I tried to use string field to add title for links in tree (see below). But if any one have better ideas how to use annotations for pages list i will glad to see it.

{{tree links="true"}}
{{velocity}}
{{html wiki=true}}
<ul>
#foreach ($child in $doc.getChildren())
  <li class="jstree-open">
  #set ($childDoc = $xwiki.getDocument($child))
  #set($anot = $childDoc.getObject('XWiki.ApiDescriptionClass'))
<a href="$xwiki.getURL($childDoc)" title="$anot.Annotation"> $xwiki.getDocument($child).getDisplayTitle()</a>
    <ul>
    #foreach ($subchild in $xwiki.getDocument($child).getChildren())
      <li class="jstree-open">
  #set ($childDoc = $xwiki.getDocument($subchild))
  #set($anot = $childDoc.getObject('XWiki.ApiDescriptionClass'))
<a href="$xwiki.getURL($childDoc)" title="$anot.Annotation"> $xwiki.getDocument($child).getDisplayTitle()</a>
        <ul>
        #foreach ($subsubchild in $xwiki.getDocument($subchild).getChildren())
          <li class="jstree-open">
            [[$subsubchild]]
            <ul>
            #foreach ($subsubsubchild in $xwiki.getDocument($subsubchild).getChildren())
              <li class="jstree-open">
                [[$subsubsubchild]]
              </li>
            #end
            </ul>
          </li>
        #end
        </ul>
      </li>
    #end
    </ul>
  </li>
#end
</ul>
{{/html}}
{{/velocity}}
{{/tree}}

So you got the metadata right but the iteration on children is not very scalable and also doesn’t show nested levels properly.

I think a more scalable solution would be to customize the Document Tree macro, see https://extensions.xwiki.org/xwiki/bin/view/Extension/Document+Tree+Macro#HCustomDocumentTree

1 Like

Thanks a lot for your help. I’ll try to take this code later.
But in fact, I chose the document tree, because I couldn’t implement anything better.

I wanted something like a page link + short annotation with accordion (slider) but couldn’t do it

When I try to put a custom tree, I see this:
image

Could you please give me an example of how to add title to links in custom three? I could not get