Latest topics
» Forumactif Edge - Releases
by Ange Tuteur Tue 03 Sep 2019, 11:49
» GIFActif - Giphy Button for the Editor
by Ange Tuteur Wed 08 May 2019, 17:21
» Forum Closure
by Ange Tuteur Mon 01 Jan 2018, 01:28
» Chit Chat Thread
by Valoish Sun 31 Dec 2017, 19:15
» Font/Text background color.
by Valoish Sun 31 Dec 2017, 19:11
» Forumactif Messenger - Instant Message Application for Forumotion
by Wolfuryo Sun 31 Dec 2017, 18:24
» [GAME] Count to One Million!
by brandon_g Fri 29 Dec 2017, 18:58
» Post Cards
by manikbiradar Wed 20 Dec 2017, 07:50
» [GAME] Countdown from 200,000
by Valoish Wed 13 Dec 2017, 23:22
» GeekPolice Tech Support Forums - GeekPolice.net
by Dr Jay Mon 11 Dec 2017, 19:12
» Asking about some plugin for Forumotion
by Dr Jay Mon 11 Dec 2017, 19:10
» [GAME] What are you thinking right now?
by Van-Helsing Sat 09 Dec 2017, 14:51
» Widget : Similar topics
by ranbac Wed 06 Dec 2017, 18:11
» Change the Background of the Forum and put an image and how to make prefixs?
by Clement Wed 06 Dec 2017, 15:19
» Hello from Western Australia
by SarkZKalie Wed 06 Dec 2017, 05:34
by Ange Tuteur Tue 03 Sep 2019, 11:49
» GIFActif - Giphy Button for the Editor
by Ange Tuteur Wed 08 May 2019, 17:21
» Forum Closure
by Ange Tuteur Mon 01 Jan 2018, 01:28
» Chit Chat Thread
by Valoish Sun 31 Dec 2017, 19:15
» Font/Text background color.
by Valoish Sun 31 Dec 2017, 19:11
» Forumactif Messenger - Instant Message Application for Forumotion
by Wolfuryo Sun 31 Dec 2017, 18:24
» [GAME] Count to One Million!
by brandon_g Fri 29 Dec 2017, 18:58
» Post Cards
by manikbiradar Wed 20 Dec 2017, 07:50
» [GAME] Countdown from 200,000
by Valoish Wed 13 Dec 2017, 23:22
» GeekPolice Tech Support Forums - GeekPolice.net
by Dr Jay Mon 11 Dec 2017, 19:12
» Asking about some plugin for Forumotion
by Dr Jay Mon 11 Dec 2017, 19:10
» [GAME] What are you thinking right now?
by Van-Helsing Sat 09 Dec 2017, 14:51
» Widget : Similar topics
by ranbac Wed 06 Dec 2017, 18:11
» Change the Background of the Forum and put an image and how to make prefixs?
by Clement Wed 06 Dec 2017, 15:19
» Hello from Western Australia
by SarkZKalie Wed 06 Dec 2017, 05:34
Recent Tutorials
Top posting users this month
Top Achievers
Who is online?
In total there are 11 users online :: 0 Registered, 0 Hidden and 11 Guests :: 2 Bots
None
Most users ever online was 515 on Tue 14 Sep 2021, 15:24
None
Most users ever online was 515 on Tue 14 Sep 2021, 15:24
Widget : Random
Page 1 of 1 • Share
What's so "Random" about this Random Widget ? The Random widget provides you with three buttons ; Random Topic, Random Forum, and Random User. Clicking any of these buttons will take you to a random topic, forum, or user on your forum.
Feeling adventurous ? Want to discover long forgotten content that you never knew existed ? Then this widget is for you !
Titles : Random
Use a table type : Your Choice
Paste the code below and save :
Once you save the widget, go back to forum widgets management and drag the widget into the column of your choice. After this you'll be able to find all kinds of random content !
1. The Style
The style of the buttons is influenced by the CSS at the very top of the widget. Modify the CSS to change the color, size, etc.. of the buttons.
2. Existence / Permission Check
Sometimes you may get an error like "The topic you are trying to view does not exist" because a topic or user has been deleted. If you're getting this many times and you find it annoying, then find the perform_check variable in the widget and set its value to true. This will perform a check to make sure that the page you're trying to view exists.
3. Editing / Removing Buttons
If you want to edit or remove buttons, you can find them at the bottom of the widget.
Those are all the notable modifications that you can make.
If you have any questions, comments, or find a bug feel free to leave a reply below. Now go on a random adventure and have fun !
Click to view demo |
Feeling adventurous ? Want to discover long forgotten content that you never knew existed ? Then this widget is for you !
Installation
To install this widget go to Admin Panel > Modules > Forum Widgets management and create a new widget with the following settings.Titles : Random
Use a table type : Your Choice
Paste the code below and save :
- Code:
<style type="text/css">#fa_random_widget a { color:#69C; border:1px solid #69C; font-family:arial, sans-serif; font-size:12px; text-align:center; border-radius:3px; padding:3px 6px; margin:6px 3px; display:block; transition:250ms; }
#fa_random_widget a:hover { color:#FFF; background:#69C; }</style>
<div id="fa_random_widget">
<script type="text/javascript">//<![CDATA[
window.FARandomTries = 0;
window.FA.Random = function(type) {
var perform_check = false,
sel = { topic : '.post', forum : '.forumbg' }, link;
type = typeof type != 'string' ? 'topic' : type.toLowerCase();
switch (type) {
case 'topic' :
link = '/t'+ ( Math.floor(Math.random() * '{FORUMCOUNTOPIC}') + 1 ) + '-';
break;
case 'forum' :
link = '/f' + ( Math.floor(Math.random() * '{FORUMCOUNTFORUM}') + 1 ) + '-';
break;
case 'user' :
link = '/u' + ( Math.floor(Math.random() * '{FORUMLASTUSERLINK}'.replace('{FORUMNAMELINK}/u', '')) + 1 );
break;
default :
alert(type + ' is not supported for randomization.');
return;
}
if (perform_check) {
if (++FARandomTries < 5) {
if (FARandomTries == 1) {
for (var a = document.getElementById('fa_random_widget').getElementsByTagName('A'), i = 0, j = a.length; i < j; i++) {
a[i].href = '#';
a[i].innerHTML = 'Please wait...';
a[i].style.opacity = '0.5';
}
}
jQuery.get(link + '?change_version=prosilver', function(d) {
if ((type == 'user' && !/<title>.*? - .*?<\/title>/.test(d)) || (type != 'user' && !jQuery(sel[type], d)[0]) || new RegExp(link).test(window.location.href)) FA.Random(type);
else window.location.href = link;
});
} else {
document.getElementById('fa_random_widget').innerHTML = window.FARandomButtons + '<p style="color:red;">The request timed out. Please try again.</p>';
window.FARandomTries = 0;
}
} else {
new RegExp(link).test(window.location.href) ? FA.Random(type) : window.location.href = link;
}
};
// Random Buttons
document.write('<a href="javascript:FA.Random(\'topic\');">Random Topic</a>');
document.write('<a href="javascript:FA.Random(\'forum\');">Random Forum</a>');
document.write('<a href="javascript:FA.Random(\'user\');">Random User</a>');
window.FARandomButtons = document.getElementById('fa_random_widget').innerHTML;
//]]></script>
</div>
Once you save the widget, go back to forum widgets management and drag the widget into the column of your choice. After this you'll be able to find all kinds of random content !

Modifications
There are a few modifications which can be made to this widget. Please read below for information on each one.1. The Style
The style of the buttons is influenced by the CSS at the very top of the widget. Modify the CSS to change the color, size, etc.. of the buttons.
- Code:
<style type="text/css">#fa_random_widget a { color:#69C; border:1px solid #69C; font-family:arial, sans-serif; font-size:12px; text-align:center; border-radius:3px; padding:3px 6px; margin:6px 3px; display:block; transition:250ms; }
#fa_random_widget a:hover { color:#FFF; background:#69C; }</style>
2. Existence / Permission Check
Sometimes you may get an error like "The topic you are trying to view does not exist" because a topic or user has been deleted. If you're getting this many times and you find it annoying, then find the perform_check variable in the widget and set its value to true. This will perform a check to make sure that the page you're trying to view exists.
- Code:
var perform_check = true,
3. Editing / Removing Buttons
If you want to edit or remove buttons, you can find them at the bottom of the widget.
- Code:
// Random Buttons
document.write('<a href="javascript:FA.Random(\'topic\');">Random Topic</a>');
document.write('<a href="javascript:FA.Random(\'forum\');">Random Forum</a>');
document.write('<a href="javascript:FA.Random(\'user\');">Random User</a>');
Those are all the notable modifications that you can make.

If you have any questions, comments, or find a bug feel free to leave a reply below. Now go on a random adventure and have fun !

Notice |
Tutorial written by Ange Tuteur. Special thanks to the Beta Testers for testing this plugin. Reproduction not permitted without consent from the author. |
Last edited by Ange Tuteur on Sat 06 Mar 2021, 14:28; edited 1 time in total
@Rhino.Freak yeah it's possible, but you'd need to create a script which will crawl that specific sub-forum so it can put all topics within that forum into an array. I don't think there's any simple way to go about it like using variables, unfortunately. 

- Sponsored content
Similar topics
Create an account or log in to leave a reply
You need to be a member in order to leave a reply.
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|