By GoVegan
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" range="others"]]
[%%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" range="others"]]
[[iframe http://snippets.wdfiles.com/local--code/code:iframe-redirect#%%link%%]]
[[/module]]
Then you make your "random link" link to that page.
In action
Limitations and their solutions
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]]
Thanks to tsangk for this great snippet: conditional-blocks
text above inserted with:
[[include :snippets:if START |unique=1|type=equal|var1=%%name%%|var2=conditional-blocks]]
**##red|Thanks to tsangk for this great snippet:##** [[[code:conditional-blocks]]]
[[include :snippets:if END]]
Other snippets posted by GoVegan
MP3 Player - 06 Jun 2021 03:45
Extended NewPage Module - 15 Jul 2014 15:08
Specific Users Only Include - 24 Jul 2013 06:16
iframe Redirect - 30 Jul 2012 22:41
Per Category CSS Module - 06 Mar 2012 03:38
Video Player - 16 Feb 2012 01:50
Remove Duplications - 16 Feb 2012 01:39
RegExp Date Wizard - 16 Feb 2012 01:39
Quoted Blockquotes - 16 Feb 2012 01:33
NewPage Button - 16 Feb 2012 01:26
JavaScript Addition - 16 Feb 2012 01:14
iframe embed - 16 Feb 2012 01:08
Random Page - 18 May 2011 09:50
Redirect - 11 Feb 2010 10:00
Rate this solution
If you think this solution is useful — rate it up!
now my site is changing pages every second and i cant undo it
"Good Day"
Is there a way for the module to generate a random link from a limited range of pages (not all other), or from a different website (on wikidot)?
I copied one of the code blocks into my main page, assuming it would be a link. So now, as soon as I click on Home, I get redirected to a random page. Just want to make sure no one makes that accident again.
(And yes, I fixed it, don't worry)
I'm a noob at WikiDot and was struggling to find/interpret coding to create a single image as a link to a random page. This is what I came up with and I thought it might help others:
1. To display an image as a link to a random page (all categories):
2. To display an image as a link to a random page (limited to certain categories):
3. To display an image as a link to a random page (limited to certain categories) and with CSS styling applied:
In version (3) - I have created a dotted border, a fixed height and a fixed width. The margin:auto; forces the fixed-width div to center in my sidebar.
See it in action, in the sidebar, at: http://cumbriaskills.wikidot.com/
It is not about what you can learn - it is about how you apply that learning…
%%page_unix_name%% is deprecated so it's better to use %%fullname%% (http://www.wikidot.com/doc:listpages-module#toc10)
Rob Elliott - Strathpeffer, Scotland - Wikidot first line support & community admin team.
Thanks Rob. Still learning - will fix mine now.
It is not about what you can learn - it is about how you apply that learning…
This page appears to be broken. It is probably caused by a link in the comments.
Thankyou! I have fixed the offending comment!
Thank you for this random feature—I need it!
I am still setting up my categories, but I want to be able to go to a random page WITHIN a particular category.
So, if I have 5 categories, would I use the same module 5 times, changing category=""*" for the name of my category?
Also, if I wanted a randomizer button, could I use this module on an image?
I have not tried this yet, but my site is at
http://marblesprings.wikidot.com/
There is supposedly an example of this script at work at http://sandbox-old.wikidot.com/choose-a-page but I can not apply to be a member?
. . category="whatever category" is the correct selection… or
Category selector:
You can putall 5 categories together ( category="cat1,cat2.." or divide them into 5 ListPages…
Service is my success. My webtips:www.blender.org (Open source), Wikidot-Handbook.
Sie können fragen und mitwirken in der deutschsprachigen » User-Gemeinschaft für WikidotNutzer oder
im deutschen » Wikidot Handbuch ?
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.
Use it with module "Listpages" and select your wished page-"range" by selection a
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 (Open source), Wikidot-Handbook.
Sie können fragen und mitwirken in der deutschsprachigen » User-Gemeinschaft für WikidotNutzer oder
im deutschen » Wikidot Handbuch ?
Thank you very much!
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
I do not understand your question… what is the same thing?
Service is my success. My webtips:www.blender.org (Open source), Wikidot-Handbook.
Sie können fragen und mitwirken in der deutschsprachigen » User-Gemeinschaft für WikidotNutzer oder
im deutschen » Wikidot Handbuch ?
Would it be possible to edit this code so it shows random pictures from the site instead of links?
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:
Hope this helps.
Timothy Foster - @tfAuroratide
Auroratide.com - Go here if you're nerdy like me