Random Page

Stefan Gross April 27, 2013

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

0 votes
Answer accepted
Matthew J. Horn
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 3, 2013

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).

1 vote
SarahA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 29, 2013

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

1 vote
m
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 28, 2013

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.

1 vote
Stefan Gross April 27, 2013

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

1 vote
darylchuah
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 27, 2013

Hi Stefan

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

Hope it helps!

Cheers :)

0 votes
Stefan Gross May 2, 2013

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

Have a nice Weekend, many greets from germany

Stefan

0 votes
m
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 28, 2013

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.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events