getDocumentsWithTag gives you documents references. To get the actual document title you will have the get the actual document ($xwiki.getDocument($reference)) and ask it for the title ($document.getRenderedTitle()).
Does not sounds like a recent version of XWiki. getRenderedTitle() gives you exactly the same thing as the displayed h1 title when you view the page (since that’s what is used there too), if there is no title it fallback on the page name and in recent version when the page name is “WebHome” it display the parent name.
i’m in version : XWiki Enterprise Jetty HSQLDB 8.4.4
I’m currently always stuck at the same point, I don’t how to do it, I tried many combinaisons, nothing work, I think I extract only the title of the page where the script is executed, but not on the page where I want to extract the title.
PS : When I wrote “TitleIWantToDisplay” in my first, post, I think it meant “Space” (after a lot of reading ^^)
Ok I read your script too fast actually (and you did not really followed what I indicated ):
$xwiki.getDocument takes a reference and return a document
then you ask the title of that document
in your script you seems to be a bit lost between what getDocument() takes and what it returns. I don’t even know why you even have something since $document is not supposed to exist (you don’t set it anywhere), maybe you inherit this variable from somewhere else.
Something else which is very dangerous in your script: don’t redefine $doc, it’s the standard binding for the current document (plus as I said that list contains references, not document so it would make much more sens to call it $reference).
Ok, my bad. I’m a debutant ^^
I modified the script. I get the good links on each occurrence but the recovered title is “WebHome&showTranslations=false” for all.
To be sure I fully understand what’s happening :
$list gets all the documents with the tag ‘Flux Internes’
$document gets the documents with all the $reference in $list
$label gets the title of each documents retrievied by $document
Foreach documents with the tag ‘Flux Internes’ (i.e each documents retrieved by $list), it displays the title of each document (i.e $label) with the link of each document (i.e $reference). I’m right ?
Ok, that what I thought, but when I tried differents codes, it display “$label” for each document instead of the title, because my variable is null (I guess)
Do I need to nest the queries ?
I try this one, I have an invalid syntax format error :
#set ($list = $xwiki.tag.getDocumentsWithTag('Flux Internes'))
#foreach($reference in $list)
[[$document.getRenderedTitle($xwiki.getDocument($reference))>>$reference]]
#end