Welcome to Geeklog Friday, October 20 2017 @ 05:28 pm EDT


Status: offline

chmouel

Forum User
Newbie
Registered: 05/02/2002
Posts: 13
Hi,
This is a Block i use to get random images displayed from a gallery. Inspiration come mainly from existing blocks i saw on this site.

You can download the script here :
http://wwww.chmouel.org/misc/lib-custom.html

Or see a preview on :
http://www.chmouel.org


Status: offline

Tony

Site Admin
Admin
Registered: 17/12/2001
Posts: 405
Location:Urbandale, Iowa
This didn't quite work for me. I did hack it a bit to get it to work but the use of srand() and rand() brought my webserver to it's knees. Turns out the built in PHP randomizer does a poor job and in many cases returns a bogus values which is really causing me problems. I tried switching to mt_srand() and mt_rand() with similar results. Anybody else have a way to do this. As it stands you would have to do a while loop until mt_rand() returns a valid value. I'll admit, I haven't complete read the PHP docs on this but if anyone has input let me konw. ----- The reason people blame things on previous generations is that there's only one other choice.
The reason people blame things on previous generations is that there's only one other choice.

Status: offline

dreamscape

Forum User
Junior
Registered: 22/01/2002
Posts: 30
that's great. i'm glad people are finally starting to code and share phpblocks for GL. Smile keep up the good work!

Status: offline

squatty

Forum User
Full Member
Registered: 21/01/2002
Posts: 269
Has anyone been able to intergrate the Gallery random image script and Geeklog?
In a world without walls and fences, who needs Windows and Gates?

Status: offline

Tony

Site Admin
Admin
Registered: 17/12/2001
Posts: 405
Location:Urbandale, Iowa
I do have the code that compliments the work on the Geeklog/Gallery integration.

You can get the two functions from here

NOTE: this code does not work well if you have albums with no pictures in it. You'll need to change the code to handle that if you have such a case (e.g. such as nothing but sub-albums in an album)

See it in action here

----- The reason people blame things on previous generations is that there's only one other choice.


The reason people blame things on previous generations is that there's only one other choice.

Status: offline

squatty

Forum User
Full Member
Registered: 21/01/2002
Posts: 269
Thanks! That's exactly what I was looking for. I created my own hack for Gallery but my version wasn't smart enough to link back inside the album. You the man!
In a world without walls and fences, who needs Windows and Gates?

Anonymous

Anonymous
Where do I need to put the code for the gallery hack?

Status: offline

efarmboy

Forum User
Full Member
Registered: 26/02/2002
Posts: 147
Thanks Tony, Copied the new functions into my GL lib-custom file and made a few edits on the $gallery variables, added the defines to my geeklog/config.php file and was up an running. I further made a quick hack to not look at a private album and filter out empty albums. Made changes to the function phpblock_random_files($g) I think you can see the changes below: // Randomly select one of the images if index counter > 2 // Anthing < is an empty album or only the highlight image // If the album is completely empty, setting the index to 1 will show a empty image but no errors if ($index > 2) { mt_srand((double)microtime()*1000000); $indexr = (mt_rand(1, count($pics))); } else { $indexr = 1;

All times are EDT. The time is now 05:28 pm.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content