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
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).
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for your answer, but how to get a random page with HTML Include? I have to provide a URL for this macro.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Stefan
Perhaps you can have can refer on HTML Include Macro documentation for more information.
Hope it helps!
Cheers :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Mary, Hello Sarah,
thanks for the help. I'll try to contact the developers.
Have a nice Weekend, many greets from germany
Stefan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.