Welcome to Geeklog Saturday, May 25 2013 @ 06:11 AM EDT
|
||||||||
![]() |
Forum Index > Extensions > PHP Blocks |
New Topic
|
Post Reply
|
PHP Blocks and 4images |
|||
| rav |
|
||||||
![]() ![]() ![]() ![]() ![]() Chatty Status: offline ![]() Registered: 01/14/03 Posts: 37 |
The geeklog & 4images integration worked perfectly, and I've been running it on my site since the day it was posted. I was wondering if anyone had any plans to do a "random photo block" for the 4images gallery. I've been poking around myself, but frankly, I'm still new to GL & PHP, and while eventually, I might be able to figure it out, I'm sure it would not be as good compared to most blocks/plugin's I've seen.
|
||||||
|
|||||||
| nurseryboy |
|
||||||
![]() ![]() ![]() ![]() ![]() Chatty Status: offline ![]() Registered: 09/04/02 Posts: 43 |
Hello,
Yes, I have created a random image block for 4images. I have been using it on my site for a while, and it seems to be working just fine. You can download the code here. Just unzip, copy the code from the file into lib-custom, and create a block in GL that calls the new function. That should be it |
||||||
|
|||||||
| rav |
|
||||||
![]() ![]() ![]() ![]() ![]() Chatty Status: offline ![]() Registered: 01/14/03 Posts: 37 |
OMG, so awesome!
Thanks!!! |
||||||
|
|||||||
| nurseryboy |
|
||||||
![]() ![]() ![]() ![]() ![]() Chatty Status: offline ![]() Registered: 09/04/02 Posts: 43 |
No problem
|
||||||
|
|||||||
| rav |
|
||||||
![]() ![]() ![]() ![]() ![]() Chatty Status: offline ![]() Registered: 01/14/03 Posts: 37 |
That worked perfectly. Thank you very much!
After playing around with it for a few hours, I noticed that it didn't seem all that random (same photo kept coming back up, more often than not. I only have about 34 images currently, but the same image would load 9 out of 10 times. I took a lil peek at your code, and read up on the rand() mysql fuction in an attempt to understand what you were doing. I cam accross this: <b>As of MySQL 3.23.52, MySQL changed the way RAND() functions, such that you MUST supply a SEED to get an actual random number. If you do not, each new connection will return close to the same number as the previous new connection. An example to test this would be to run the follow command multiple times in a row. mysql -u username -p -e'select rand()' A basic way to seed this would be to run RAND(NOW()).</b> So I added the NOW() function to the RAND() and it totaly cured it for me. It seems much more random now, and I'm seeing images that were not showing up before. Once again, thanks for the block, I know I couldn't have done it, but maybe this lil tweak will help others |
||||||
|
|||||||
| nurseryboy |
|
||||||
![]() ![]() ![]() ![]() ![]() Chatty Status: offline ![]() Registered: 09/04/02 Posts: 43 |
Ok, cool. Thanks for finding that out. I will add it to the code right away.
I'm glad it is working fine for you too. Have a great day! |
||||||
|
|||||||
| Anonymous: Anonymous |
|
||||||
|
|
I like this block....
The RAND(NOW()) function did not work for me. I kept getting the same image every time. I found this in a post on mysql.com: MD5(RAND()) This worked every time for me. Hope this helps.... |
||||||
|
|||||||
| Content generated in: 0.21 seconds |
|
|
|