"Random Page!" link

Description

Previously, before the order="random" attribute was available, there was no way to have a link which would display a random page.

The workaround used was the "single block of many pages" technique.

However, since the creation of this new attribute, it has become possible to use the ListPages module to create this.

Code

[[module ListPages category="*" order="random" limit="1" skipCurrent="true"]]
[%%link%% Random page!]
[[/module]]

In action

Alternative

In some web-browsers, the URL is shown as the user hovers the mouse over it. If you don't want the user to see the URL of the page on a mouse-hover, then you should create a "Random Page" page containing the following code:

[[module ListPages category="*" order="random" limit="1" skipCurrent="true"]]
[[div]]
[[/div]]
[!-- The above div block may seem superfluous, but it is necessary for formatting --]
[[size 190%]]Random Page: %%title%%[[/size]] ([%%link%% view original])
[[div style="border-top: 1px solid #666;"]]
[[/div]]
%%content%%
[[/module]]

Then you make your "random link" link to that page. It is recommended that you have no page title on the "Random Page" page, so that the user is not confused with a double title being displayed (i.e. Remove the text automatically applied to the "Title of the page:" text box).

In action

Choose a random snippet!

Limitations and solutions to limitations

Due to the nature of the order="random" attribute, the "random" page is not selected on the spot (it changes every 60 seconds).

Solutions

The solution to this limitation would be to place it in the side bar, because the link is different on every page loaded. More explained, you can click the link in the side bar, and the loaded page will have a fresh new link in the same side navigator (so you can click it again).

Thanks to James Kanjo putting random page link in the top bar is also possible. The trick is that closing module brackets ([[/module]]), must be put AFTER the other links or buttons you have in your top bar, i.e. all other links and buttons must be placed inside the ListPages module.

Here:

[[module ListPages category="whatever category" order="random" limit="1" skipCurrent="true"]]
* [%%link%% Random page]
* Home
* Whatever link
* Whatever link
* Print button
* Edit button
* Any other button or link
[[/module]]

It is not necessary that Random page link gets the first on the list. You can put it wherever you want, but it must stay inside module brackets.

[[module ListPages category="whatever category" order="random" limit="1" skipCurrent="true"]]
* Home
* Whatever link
* Whatever link
* **[%%link%% Random page]**
* Print button
* Edit button
* Any other button or link
[[/module]]

Rate this solution

If you think this solution is useful — rate it up! Or dump it otherwise.

rating: +6+x

Comments

pictures
darlodarlo 1227862804|%e %b %Y, %H:%M %Z|agohover

Would it be possible to edit this code so it shows random pictures from the site instead of links?

unfold pictures by darlodarlo, 1227862804|%e %b %Y, %H:%M %Z|agohover
Re: pictures
Timothy FosterTimothy Foster 1228076215|%e %b %Y, %H:%M %Z|agohover

Well, I believe so. That is what I am doing right now. What you do is create a page for each image. The name would be image:name of picture, and the content would simply be the url and nothing else. Then, use a ListPages like this:

[[module ListPages category="image" order="random" limit="1"]]
[[image %%content%%]]
[[/module]]

Hope this helps.
tarmsig.png

Timothy FosterMy Site ~ My Blog
lhbanner.png

unfold Re: pictures by Timothy FosterTimothy Foster, 1228076215|%e %b %Y, %H:%M %Z|agohover
ArabianPrincessArabianPrincess 1230419775|%e %b %Y, %H:%M %Z|agohover

Is there a way to keep it random within a set of pages? I have one section of a category, and I would like to keep the random page limited to my own pages.

unfold by ArabianPrincessArabianPrincess, 1230419775|%e %b %Y, %H:%M %Z|agohover
Re:
Helmuti_pdorfHelmuti_pdorf 1230455654|%e %b %Y, %H:%M %Z|agohover

Use it with module "Listpages" and select your wished page-"range" by selection a

  • category="…" ( or "*" ) and
  • tags="+yourtagname" !

You should tag your pages with perhaps a word like your username - "shortcode" perhaps :) - and you can select here with a plus sign …
If you do not want to see these tagname on a tag cloud than you can start such tagname with an underscore!


Service is my success. My webtips:www.blender.org, www.zusi.de (Demo-Video)

Wollen Sie Wikidot helfen im deutschen » Handbuch ?

unfold Re: by Helmuti_pdorfHelmuti_pdorf, 1230455654|%e %b %Y, %H:%M %Z|agohover
Re:
ArabianPrincessArabianPrincess 1230849473|%e %b %Y, %H:%M %Z|agohover

Thank you very much!

unfold Re: by ArabianPrincessArabianPrincess, 1230849473|%e %b %Y, %H:%M %Z|agohover
Re:
Lola92Lola92 1237595146|%e %b %Y, %H:%M %Z|agohover

ok i am wondering the same thing.. Can you please put that in simplier forms.. cause none of that made complete sense in where to put it..

please and thanks

unfold Re: by Lola92Lola92, 1237595146|%e %b %Y, %H:%M %Z|agohover
Re: ? ?
Helmuti_pdorfHelmuti_pdorf 1237796745|%e %b %Y, %H:%M %Z|agohover

ok i am wondering the same thing.. Can you please put that in simplier forms..

I do not understand your question… what is the same thing?

  • the limitatin to some "own" pages ?
  • or the question with the Image-urls?

Service is my success. My webtips:www.blender.org, www.zusi.de (Demo-Video)

Wollen Sie Wikidot helfen im deutschen » Handbuch ?

unfold Re: ? ? by Helmuti_pdorfHelmuti_pdorf, 1237796745|%e %b %Y, %H:%M %Z|agohover

Add your comment

Add a new comment
page_revision: 6, last_edited: 1229094984|%e %b %Y, %H:%M %Z (%O ago)
Unless stated otherwise Content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License