[Solved] Include reference but images missing

Hi.
I made a page showing me a random page. This is what I have now:

{{velocity}}
  ## Count all articles
  #set ($xwql = "where doc.creationDate > '2021-08-30' AND doc.content NOT LIKE '%NOT MIGRATED%'")
  #set ($count = $services.query.xwql($xwql).count())
  ## == $count Seiten gefunden ==
{{/velocity}}

{{groovy}}
  // Because velocitys mathtool isn't working create random number with groovy and use $count as max. value
  // velocity "$count" is groovy "count"
  print "Zeige Seite "
  randomnumber = Math.abs(new Random().nextInt() % count)
  print randomnumber
  print " von "
  print count
  println " Seiten:"
{{/groovy}}

----

{{velocity}}
## groovy "randomnumber" is velocity "$randomnumber"
## Velocity random: $randomnumber

## --- Array aller Seiten
#set ($allItems = $services.query.xwql($xwql).execute())

## randoms Seiten-Ăśberschrift als Link zur Seite
= [[$allItems[$randomnumber]]] =
----

## --- random Seite anzeigen ---
{{include reference="$allItems[$randomnumber]" /}}
{{/velocity}}

It works but it doesn’t show the images from that random page.
Any ideas?

Regards Simpel

This includes the content of the target page as is (so relative references become relative to the current page). If you want to display a page in its own context, you can use the display macro instead, as in

{{display reference="$allItems[$randomnumber]" /}}
1 Like

That works perfectly. Thanks.

Simpel