Author |
Message |
megabyte2001
New Member
![New Member New Member](modules/Forums/images/ranks/1star.gif)
![](modules/Forums/images/avatars/gallery/blank.gif)
Joined: Apr 15, 2006
Posts: 9
|
Posted:
Tue Nov 28, 2006 4:37 pm |
|
I'm looking for a block that will display other blocks at random or by list.
One time it might show block-1.php, then after a refresh, block-2.php and so on and so forth.
Anyone heard of such a thing or know how to code this? |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
kguske
Site Admin
![](modules/Forums/images/avatars/41f0b40a419280935f3a0.gif)
Joined: Jun 04, 2004
Posts: 6437
|
Posted:
Tue Nov 28, 2006 4:48 pm |
|
Interesting... You could try randomly including the other blocks in the random blocks block file. |
_________________ I search, therefore I exist...
Only registered users can see links on this board! Get registered or login! |
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
megabyte2001
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Tue Nov 28, 2006 6:20 pm |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
gregexp
The Mouse Is Extension Of Arm
![](modules/Forums/images/avatars/458c161744a70db912a6e.jpg)
Joined: Feb 21, 2006
Posts: 1497
Location: In front of a screen....HELP! lol
|
Posted:
Tue Nov 28, 2006 8:32 pm |
|
Thanks for the laugh guys.megabyte2001, when I first came here, boy how many times did I think to myself to type Just that.
kguske, you have the exact idea I was thinking about.
Now megabyte, do you want this to show blocks that are not active?
Basically all types of blocks?
After thinking about this I was thinking to using another directory.
Paste this in your BEST text editor:
<?php
if ( !defined('BLOCK_FILE') ) {
Header("Location: ../index.php");
die();
}
$directory='random_blocks';
$countrand=0;
if (!($handlerand = opendir($directory))) {
die('Failure to read from '.$directory);
}
//right from php.net, no reason to reinvent the wheel.
while (false !== ($file = readdir($handlerand))) {
if(($file!=='.')AND($file!='..')){
$countrand=$countrand+1;
//This turns it into an array to later be used.
$file_name[$countrand]=$file;
}
}
$rnum=rand(1,$countrand);//Dont need to use anymore then we already have
include($file_name[$rnum]);
?>
Now name it something like block-Random_blocks.php.
Now you have the block that will have the random_blocks you selected.
In your site root, make a folder called random_blocks, upload the blocks you want it to use.
Hope you find this to be what you are looking for. |
_________________ For those who stand shall NEVER fall and those who fall shall RISE once more!! |
|
![ICQ Number ICQ Number](themes/RavenIce/forums/images/lang_english/icon_icq_add.gif) |
![](themes/RavenIce/forums/images/spacer.gif) |
gregexp
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Tue Nov 28, 2006 10:55 pm |
|
Now this is tested, but not tested against security, I dont really see anything that would cause any security issue, I cant see how this could be hijacked or placed under attack. Hope you find it usefull. |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
megabyte2001
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Wed Nov 29, 2006 6:32 am |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
kguske
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Wed Nov 29, 2006 7:07 am |
|
Thanks, darklord - that was what I had in mind - just didn't have the time to put the code together and test. Nice job! |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
gregexp
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Wed Nov 29, 2006 7:25 am |
|
Glad it worked for you. ![RavensScripts](modules/Forums/images/smiles/ravensphpscripts.gif) |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
|