Welcome to Geeklog Thursday, November 21 2019 @ 11:13 am EST

Geeklog Forums

phpblock not showing


Status: offline

tgc

Forum User
Regular Poster
Registered: 15/03/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:
[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"Wink;
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"Wink{
$names1[$tempvar]=$names[$i];$tempvar++;
}
}

$random = mt_rand(1, $tempvar);

$image_name = $random . $file_type;
$text_name = $random . $text_file_type;

}
// end random[/code]
The block is not showing at all, not even an error message.
Any ideas?

Thank you/Frank
 Quote

Status: offline

suprsidr

Forum User
Full Member
Registered: 29/12/04
Posts: 555
Location:Champaign, Illinois
need to return something?

-s
FlashYourWeb and Your Gallery with the E2 XML Media Player for Gallery2 - http://www.flashyourweb.com
 Quote

Status: offline

suprsidr

Forum User
Full Member
Registered: 29/12/04
Posts: 555
Location:Champaign, Illinois
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
 Quote

Status: offline

tgc

Forum User
Regular Poster
Registered: 15/03/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
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 12/01/02
Posts: 13073
Location:Stuttgart, Germany
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
 Quote

Status: offline

tgc

Forum User
Regular Poster
Registered: 15/03/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
 Quote

Status: offline

suprsidr

Forum User
Full Member
Registered: 29/12/04
Posts: 555
Location:Champaign, Illinois
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 Wink

-s
FlashYourWeb and Your Gallery with the E2 XML Media Player for Gallery2 - http://www.flashyourweb.com
 Quote

Status: offline

tgc

Forum User
Regular Poster
Registered: 15/03/06
Posts: 82
thank you s but I am not using Gallery 2 right now...

Frank
 Quote

Status: offline

suprsidr

Forum User
Full Member
Registered: 29/12/04
Posts: 555
Location:Champaign, Illinois
Oops sorry almost forgot about you.
try:
[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;
}
[/code]

-s
FlashYourWeb and Your Gallery with the E2 XML Media Player for Gallery2 - http://www.flashyourweb.com
 Quote

Status: offline

tgc

Forum User
Regular Poster
Registered: 15/03/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
 Quote

Status: offline

tgc

Forum User
Regular Poster
Registered: 15/03/06
Posts: 82
the code for the linked page is like this:[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"; ?>[/code]
like I said, I am not the php guy, maybe something needs to be added to the code for the block?

Frank
 Quote

Status: offline

tgc

Forum User
Regular Poster
Registered: 15/03/06
Posts: 82
no ideas how I can integrate this to my block?

Thanks/Frank
 Quote

Status: offline

suprsidr

Forum User
Full Member
Registered: 29/12/04
Posts: 555
Location:Champaign, Illinois
My example works..... still.

-s
FlashYourWeb and Your Gallery with the E2 XML Media Player for Gallery2 - http://www.flashyourweb.com
 Quote

Status: offline

tgc

Forum User
Regular Poster
Registered: 15/03/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 Big Grin

Thanks/Frank
 Quote

All times are EST. The time is now 11:13 am.

  • 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