I'm trying to create an automatic Index where all the pages from the spaces will be displayed. Something like:
- Space 1 (public)
- Page 1 (public)
- Page 2 (private)
- Page 2.1 (public)
- Space 2 (public)
- Page A (private)
- Page B (public)
Where:
- public: (Rights:
Read=True
) user can click to access the content. - private: (Rights:
Read=False
) user can see the title but can't click.
If the user has no rights to read
the page I want that at least he can get to see the title of the page as I can continue listing the pages that are able to read
in the child.
What I have:
#foreach($space in $xwiki.spaces)
#set($WebHome = $space + ".WebHome")
#getChildrenOf($WebHome)
#end
Now the recursive getChildrenOf
macro is:
#macro(getChildrenOf, $docName)
#foreach($name in $xwiki.searchDocuments('where doc.parent = ? or doc.parent = ? order by doc.name', [$docName, "xwiki:$docName"]))
#if($xwiki.hasAccessLevel('view', "xwiki:$name"))
[[$xwiki.getDocument($name).getPlainTitle()>>$name]]
#else
$xwiki.getDocument($name).getPlainTitle()
#end
#getChildrenOf($name)
#end
#end
Results:
In the
else
i'm getting a plain text showing the function$xwiki.getDocument($name).getPlainTitle()
instead of the title of the Page.If I just write
$name
in theelse
what I get is:Space_1.Page_2
instead of the title of Page 2.
Why is that happening? How can I solve it?