Is there any way to link to a random page in confluence like in media wiki? Can't find a macro/plugin for that. I don't have the reporting plugin. Does anyone have a little JS for that for a user macro? Thanks in advance, Stefan

7 answers

1 accepted

This widget could not be displayed.

If this doesn't work out, you can write a macro to do it, but you'll need to do a bit of work to get it going:

1) Add the org.apache.velocity.tools.generic.MathTool class to the Velocity context (this is so you can generate a random number in your macro) -- instructions are here (you'll need to modify the XML file to get the Math class rather than the Sorter that the instructions use): https://answers.atlassian.com/questions/62575/use-of-velocity-generic-tools-in-a-page-decorator

2) Create the macro:

a) Get a count of how many pages are in the space.

b) Generate a random number between 0 and the count.

c) Use some logic to get the page at the index matching your random number (one way to do this is to call getSortedChildren() on the root page of the space. This returns a List of Pages. Then get the page with the Lists class's get() method, which takes an index.

d) Use Page class's getUrlPath() method (or maybe you can do it with just getDisplayTitle()) to add a link to the page (I think this will do it, but there's no doc for that method, so I'm not sure).

This widget could not be displayed.
Daryl Chuah Atlassian Team Apr 27, 2013

Hi Stefan

Perhaps you can have can refer on HTML Include Macro documentation for more information.

Hope it helps!

Cheers :)

This widget could not be displayed.

Thanks for your answer, but how to get a random page with HTML Include? I have to provide a URL for this macro.

This widget could not be displayed.

If I understand you correctly, you want a function that randomly selects a page from the Confluence database and displays it to the user. For example, you might have a Space that contains help for your company --- so you might randomly want to show these to users when the login --- sort of like a revolving splash page in a GUI.

Confluence doesn't have the equivalent. You could possibly quickly write a user macro that did this.

This widget could not be displayed.

Hallo Stefan

There used to be a plugin that supplied a "random include" macro, but that plugin is no longer available. What I have found is the Java source of the original plugin that supplies the macro: https://svn.atlassian.com/svn/public/contrib/confluence/include-random-plugin/trunk/src/main/java/com/macadamian/confluence/macros/includerandom/IncludeRandom.java

At the top of that file are the names of the developers. It may be worth contacting them to see if they plan to update the macro to work in later versions of Confluence.

I hope this gets you some of the way there!

Cheers, Sarah

This widget could not be displayed.

If I understand you correctly, you want a function that randomly selects a page from the Confluence database and displays it to the user. For example, you might have a Space that contains help for your company --- so you might randomly want to show these to users when the login --- sort of like a revolving splash page in a GUI.

Confluence doesn't have the equivalent. You could possibly quickly write a user macro that did this.

This widget could not be displayed.

Hello Mary, Hello Sarah,
thanks for the help. I'll try to contact the developers.

Have a nice Weekend, many greets from germany

Stefan

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Sep 17, 2018 in Confluence

Why start from scratch? Introducing four new templates for Confluence Cloud

Hi my Community friends!  For those who don't know me, I'm a product marketer on the Confluence Cloud team - nice to meet you! For those of you who do, you know that I've been all up in your Co...

542 views 7 6
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you