MyBB Community Forums

Full Version: Random Pages
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have a new project that I'm working on with friends. One of our things will be a Random Pages Segment. I don't want it to be like you have to search for new things, but rather that when you click on this link it will take you to a random page, not a predetermined one. And every time you click it it brings to you a different page. Would this be simple to do?
(2009-02-15, 06:57 AM)MCII-Totality Wrote: [ -> ]I have a new project that I'm working on with friends. One of our things will be a Random Pages Segment. I don't want it to be like you have to search for new things, but rather that when you click on this link it will take you to a random page, not a predetermined one. And every time you click it it brings to you a different page. Would this be simple to do?
It might be more complex than what I'm thinking, but yes.. Note that this probably won't work, just an example..

$pages = array();
$page_names = array();
$pages[0] = "index.php";
$page_name[0] = "Home";
$pages[1] = "page1.php";
$page_name[1] = "Page 1";
$pages[2] = "page2.php";
$page_name[2] = "Page 2";
$pages[3] = "pagelol.php";
$page_name[3] = "Page lol";

if(count($pages) > 0)
{
for($i = 0; $i < count($pages); $i++)
{
$link = rand($pages[$i]);
$title = rand($page_names[$i]);
echo "<a href=".$link.">".$title."</a>";
}
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Solid Corruption| Home</title>
<meta name="keywords" content="Boredom, Corruption, Random, Politics, Bunnies, KillBunny, Sexy, Totality, Notebook, Pedro, Chat Room, Comic Books" />
<meta name="description" content="If you've ever been bored before, and I'm sure you have, you may want to just stay here. We will make sure that as long as we live you are not bored. We have certain things that you can only find here: KillBunnys, The Notebook, The Chat Room, and The Comic. I hope you like it ;)" />
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="header"><a href="index.html"><img src="images/logo.png" alt="Solid Corruption | Where fun has no limit" /></a></div>
<div id="nav">
<ul>
<li><a href="affiliates">Affiliates</a>
<ul>
<li><a href="affiliates/sucu-lang">Sucu-Lang</a></li>

<li><a href="affiliates/crossfyr">CrossFyr</a></li>
<li><a href="affiliates/world">The WorldRP</a></li>
<li><a href="affiliates/partner">Affiliation/Partnership</a></li></ul></li>
<li><a href="downloads">Download</a>
<ul>
<li><a href="downloads/kbunny">KillBunny</a></li>
<li><a href="downloads/notebook">The NoteBook</a></li>
<li><a href="downloads/randomness">Random Downloads</a></li></ul></li>
<li><a href="blog">Blog</a>

<ul>
<li><a href="blog">News</a></li>
<li><a href="blog">KillBunny</a></li>
<li><a href="blog">The Notebook</a></li></ul></li>
<li><a href="forums">Forums</a>
<ul>
<li><a href="forums/portal.php">Portal</a></li>
<li><a href="forums/usercp.php">UserCP</a></li>
<li><a href="forums/private.php">Private Messages</a></li>
<li><a href="forums/search.php?action=getdaily">New Posts</a></li>

<li><a href="forums/forumdisplay.php?fid=2">Announcements</a></li></ul></li>
<li><a href="index.html">Solid Corruption</a>
<ul>
<li><a href="killbunny">KillBunny</a></li>
<li><a href="notebook">The Notebook</a></li>
<li><a href="chatroom">The Chat Room</a></li>
<li><a href="comics">The Comics</a></li>
<li><a href="randomness">Random Pages</a></li></ul></li></ul>	</div>
<div id="wraper">

<div id="center">
<h2>Welcome!</h2>
<p>And welcome to SolidCorruption.com! This place is home the brain-children of Connor McCorkle, Miguel Cosme, Taylor &quot;Gustov&quot; Wilks, Max Cosme, and many others. As of now, our main focuses are The NoteBook and KillBunny.</p>
<h2>About us:</h2>
<p>We are SolidCorruption.com We are the brain-child of Miguel, Gustov, Max, Ben, Connor, Deacon, &quot;Ninja&quot;, and many others. Our main focus as of now is our KillBunnys. KillBunnys are little 1 picture scene that shows you a different way the bunny will die or has died. This is not meant to be demonic or evil, it is meant to be humourus and funny (and boy is it!). We also have a place where fans and critics can gather and comment on our work, but also basically live here. It's called the forums and they are built in with an Arcade, a Video Gallery, a Virtual Shop, a Shoutbox, Awards, and so much more fun. So, stroll on over to our <a href="forums">Forums</a>.</p></div>
<div id="right">

<h2>Updates:</h2>
<p>We are all working diligently to improve the site and its contents. Please wait patiently for more updates. While you are waiting, you may register on our <a href="forums">forums</a> and help us improve our site.</p></div></div>
<div class="footer">
<p class="translate">To translate this and all pages here into Sucu, click <a href="sucu.html">here</a></p>
			    Design by <a href="http://indiepaper.com">Combus</a></div>
</body>
</html>

How would that fit in all of this?
(2009-02-15, 07:21 AM)MCII-Totality Wrote: [ -> ]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Solid Corruption| Home</title>
<meta name="keywords" content="Boredom, Corruption, Random, Politics, Bunnies, KillBunny, Sexy, Totality, Notebook, Pedro, Chat Room, Comic Books" />
<meta name="description" content="If you've ever been bored before, and I'm sure you have, you may want to just stay here. We will make sure that as long as we live you are not bored. We have certain things that you can only find here: KillBunnys, The Notebook, The Chat Room, and The Comic. I hope you like it ;)" />
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="header"><a href="index.html"><img src="images/logo.png" alt="Solid Corruption | Where fun has no limit" /></a></div>
<div id="nav">
<ul>
<li><a href="affiliates">Affiliates</a>
<ul>
<li><a href="affiliates/sucu-lang">Sucu-Lang</a></li>

<li><a href="affiliates/crossfyr">CrossFyr</a></li>
<li><a href="affiliates/world">The WorldRP</a></li>
<li><a href="affiliates/partner">Affiliation/Partnership</a></li></ul></li>
<li><a href="downloads">Download</a>
<ul>
<li><a href="downloads/kbunny">KillBunny</a></li>
<li><a href="downloads/notebook">The NoteBook</a></li>
<li><a href="downloads/randomness">Random Downloads</a></li></ul></li>
<li><a href="blog">Blog</a>

<ul>
<li><a href="blog">News</a></li>
<li><a href="blog">KillBunny</a></li>
<li><a href="blog">The Notebook</a></li></ul></li>
<li><a href="forums">Forums</a>
<ul>
<li><a href="forums/portal.php">Portal</a></li>
<li><a href="forums/usercp.php">UserCP</a></li>
<li><a href="forums/private.php">Private Messages</a></li>
<li><a href="forums/search.php?action=getdaily">New Posts</a></li>

<li><a href="forums/forumdisplay.php?fid=2">Announcements</a></li></ul></li>
<li><a href="index.html">Solid Corruption</a>
<ul>
<li><a href="killbunny">KillBunny</a></li>
<li><a href="notebook">The Notebook</a></li>
<li><a href="chatroom">The Chat Room</a></li>
<li><a href="comics">The Comics</a></li>
<li><a href="randomness">Random Pages</a></li></ul></li></ul>	</div>
<div id="wraper">

<div id="center">
<h2>Welcome!</h2>
<p>And welcome to SolidCorruption.com! This place is home the brain-children of Connor McCorkle, Miguel Cosme, Taylor &quot;Gustov&quot; Wilks, Max Cosme, and many others. As of now, our main focuses are The NoteBook and KillBunny.</p>
<h2>About us:</h2>
<p>We are SolidCorruption.com We are the brain-child of Miguel, Gustov, Max, Ben, Connor, Deacon, &quot;Ninja&quot;, and many others. Our main focus as of now is our KillBunnys. KillBunnys are little 1 picture scene that shows you a different way the bunny will die or has died. This is not meant to be demonic or evil, it is meant to be humourus and funny (and boy is it!). We also have a place where fans and critics can gather and comment on our work, but also basically live here. It's called the forums and they are built in with an Arcade, a Video Gallery, a Virtual Shop, a Shoutbox, Awards, and so much more fun. So, stroll on over to our <a href="forums">Forums</a>.</p></div>
<div id="right">

<h2>Updates:</h2>
<p>We are all working diligently to improve the site and its contents. Please wait patiently for more updates. While you are waiting, you may register on our <a href="forums">forums</a> and help us improve our site.</p></div></div>
<div class="footer">
<p class="translate">To translate this and all pages here into Sucu, click <a href="sucu.html">here</a></p>
			    Design by <a href="http://indiepaper.com">Combus</a></div>
</body>
</html>

How would that fit in all of this?
As I said before, it wouldn't - it's just an example.
oh ok. Sorry. I didn't realize
(2009-02-15, 07:24 AM)MCII-Totality Wrote: [ -> ]oh ok. Sorry. I didn't realize
It's alright, no problem.
(2009-02-15, 06:57 AM)MCII-Totality Wrote: [ -> ]I have a new project that I'm working on with friends. One of our things will be a Random Pages Segment. I don't want it to be like you have to search for new things, but rather that when you click on this link it will take you to a random page, not a predetermined one. And every time you click it it brings to you a different page. Would this be simple to do?

Javascript FTW?


Source:
http://javascript.internet.com/navigatio...-page.html


<!-- ONE STEP TO INSTALL RANDOM PAGE:

  1.  Copy the coding into the HEAD of your HTML document  -->

<!-- STEP ONE: Paste this code into the HEAD of your HTML document  -->

<HEAD>

<SCRIPT LANGUAGE="JavaScript">

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
var howMany = 2;  // max number of items listed below
var page = new Array(howMany+1);

page[0]="first-random-page.html";
page[1]="second-random-page.html";
page[2]="third-random-page.html";

function rndnumber(){
var randscript = -1;
while (randscript < 0 || randscript > howMany || isNaN(randscript)){
randscript = parseInt(Math.random()*(howMany+1));
}
return randscript;
}
quo = rndnumber();
quox = page[quo];
window.location=(quox);
// End -->
</SCRIPT>
</HEAD>

<p><center>
<font face="arial, helvetica" size="-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
</center><p>

<!-- Script Size:  0.89 KB -->

Can't say that that isn't as perfect for your needs. Any issue Pm me.