Welcome to Geeklog Friday, May 24 2013 @ 03:21 AM EDT
|
||||||||
![]() |
Forum Index > Extensions > PHP Blocks |
New Topic
|
Post Reply
|
phpblock not showing |
|||
| tgc |
|
||||||
![]() ![]() ![]() ![]() ![]() Regular Poster Status: offline ![]() Registered: 03/15/06 Posts: 82 |
I want to do a random image block with selected images which then link to certain URLs.
I found one script which works on a regular page on my server, have a look here. But when I add this (and the corresponding phpblock) as a function to lib-custom like this: PHP Formatted Code function phpblock_random(){ $file_type = ".jpg"; $text_file_type = ".txt"; $image_folder = "images"; $handle = opendir("/xxx/x/duvide.com/public_html/random/$image_folder"); while ($file = readdir($handle)) $names[count($names)] = $file; closedir($handle); sort($names); for ($i=0;$names[$i];$i++){ $ext=strtolower(substr($names[$i],-4)); if ($ext==".jpg"){ $names1[$tempvar]=$names[$i];$tempvar++; } } $random = mt_rand(1, $tempvar); $image_name = $random . $file_type; $text_name = $random . $text_file_type; } // end random The block is not showing at all, not even an error message. Any ideas? Thank you/Frank |
||||||
|
|||||||
| suprsidr |
|
||||||
![]() ![]() ![]() ![]() ![]() Full Member Status: offline ![]() Registered: 12/29/04 Posts: 552 |
need to return something?
-s FlashYourWeb and Your Gallery with the E2 XML Media Player for Gallery2 - http://www.flashyourweb.com |
||||||
|
|||||||
| suprsidr |
|
||||||
![]() ![]() ![]() ![]() ![]() Full Member Status: offline ![]() Registered: 12/29/04 Posts: 552 |
Geeklog has 2 image gallery plugins each of which have imageblock functionality BTW.
-s FlashYourWeb and Your Gallery with the E2 XML Media Player for Gallery2 - http://www.flashyourweb.com |
||||||
|
|||||||
| tgc |
|
||||||
![]() ![]() ![]() ![]() ![]() Regular Poster Status: offline ![]() Registered: 03/15/06 Posts: 82 |
if you are in the know, please tell me the code I need in order to get it running. I am not a php guy, in case you have not noticed.
I know there are image galleries but their random blocks don't do what I need. Thank you |
||||||
|
|||||||
| Dirk |
|
||||||
![]() ![]() ![]() ![]() ![]() Admin ![]() Status: online ![]() Registered: 01/12/02 Posts: 13027 |
A PHP block should return the HTML that Geeklog will then display in the block. However, the above code doesn't really do anything from what I can see. So it's not only the missing return statement - it's not clear what that code is supposed to do in the first place ...
bye, Dirk |
||||||
|
|||||||
| tgc |
|
||||||
![]() ![]() ![]() ![]() ![]() Regular Poster Status: offline ![]() Registered: 03/15/06 Posts: 82 |
it should do what it does on this link but in a block in geeklog:
with each refresh it changes the images randomly. Very simple I would think. Thanks for your help/Frank |
||||||
|
|||||||
| suprsidr |
|
||||||
![]() ![]() ![]() ![]() ![]() Full Member Status: offline ![]() Registered: 12/29/04 Posts: 552 |
My G2Bridge for Gallery2 allows for the use of my Minislideshow or MediaBlock or even autotags to accomplish your goal.
Wondering if I got enough urls in there -s FlashYourWeb and Your Gallery with the E2 XML Media Player for Gallery2 - http://www.flashyourweb.com |
||||||
|
|||||||
| tgc |
|
||||||
![]() ![]() ![]() ![]() ![]() Regular Poster Status: offline ![]() Registered: 03/15/06 Posts: 82 |
thank you s but I am not using Gallery 2 right now...
Frank |
||||||
|
|||||||
| suprsidr |
|
||||||
![]() ![]() ![]() ![]() ![]() Full Member Status: offline ![]() Registered: 12/29/04 Posts: 552 |
Oops sorry almost forgot about you.
try: PHP Formatted Code function phpblock_random_images() { global $_CONF; $image_directory = '/images/'; $link = $_CONF['site_url']; $pattern = ".jpg$"; $files = array (); $display = ''; if ($handle = opendir($_CONF['path_html'].$image_directory)) { while ($file = readdir($handle)) { if (eregi($pattern, $file)) { $files[] = $file; } } shuffle($files); $file = $_CONF['path_html'].$image_directory.$files[0]; list ($width, $height, $type, $attr) = getimagesize($file); $display .= '<a href="'.$link.'"><img src="'.$_CONF['site_url'] .$image_directory.$files[0].'" '.$attr .' alt="'.$files[0].'" title="'.$files[0].'"></a>'; closedir($handle); } return $display; } -s FlashYourWeb and Your Gallery with the E2 XML Media Player for Gallery2 - http://www.flashyourweb.com |
||||||
|
|||||||
| tgc |
|
||||||
![]() ![]() ![]() ![]() ![]() Regular Poster Status: offline ![]() Registered: 03/15/06 Posts: 82 |
Thank you for your effort -s.
But this is not the script I need to incorporate into the block. Why is my script working on a normal page but not in the geeklog blog? That is would I would like to solve. Frank |
||||||
|
|||||||
| tgc |
|
||||||
![]() ![]() ![]() ![]() ![]() Regular Poster Status: offline ![]() Registered: 03/15/06 Posts: 82 |
the code for the linked page is like this:
PHP Formatted Code <?php include "/xxx/x/duvide.com/public_html/random/random.php";echo "<img src=\"$image_folder/$image_name\" alt=\"$image_name\" />"; include "$image_folder/$text_name"; ?> like I said, I am not the php guy, maybe something needs to be added to the code for the block? Frank |
||||||
|
|||||||
| tgc |
|
||||||
![]() ![]() ![]() ![]() ![]() Regular Poster Status: offline ![]() Registered: 03/15/06 Posts: 82 |
no ideas how I can integrate this to my block?
Thanks/Frank |
||||||
|
|||||||
| suprsidr |
|
||||||
![]() ![]() ![]() ![]() ![]() Full Member Status: offline ![]() Registered: 12/29/04 Posts: 552 |
My example works..... still.
-s FlashYourWeb and Your Gallery with the E2 XML Media Player for Gallery2 - http://www.flashyourweb.com |
||||||
|
|||||||
| tgc |
|
||||||
![]() ![]() ![]() ![]() ![]() Regular Poster Status: offline ![]() Registered: 03/15/06 Posts: 82 |
Hi -s, it works but not like I need it to work. I want only certain images displayed randomly linking to a certain URL and I want a caption. My standalone script does this and I just would like to have it in a block. Is this too much to ask for
Thanks/Frank |
||||||
|
|||||||
| Content generated in: 1.33 seconds |
|
|
|