PDA

View Full Version : Custom PHP Sidebar/Block Issues


MrSeth
11-18-2012, 07:39 PM
I created a custom php block that pulls a random image from a directory on my server.

However, I'm having 2 issues.

1. Its pulling 2 images instead of just one.

2. Its placing the images above the header and not in a sidebar/block.

kh99
11-19-2012, 09:33 AM
Your widget code needs to set $output to the html for your widget instead of using ?> and <?php or echo. Try this:

$dir = "user-uploads-thumbnails/";
$images = scandir($dir);
$i = rand(1, sizeof($images)-5);

$output = '<a> <a href="user-uploads/' . $images[$i] . '">
<img src="user-uploads-thumbnails/' . $images[$i] . '" alt="" /> <a/>';