Gallery 2 Image Block - 12 random images?

eon03

Joined: 2005-07-18
Posts: 4
Posted: Tue, 2006-08-01 07:39

I am trying to figure out how to have a block, external to my gallery that shows 12 random images in rows of 3 with each item linking back to the original in the gallery. I had this on my old installation but upgraded today to G2 and am having no luck so far. Anyone else make this happen?

 
drakke

Joined: 2005-08-14
Posts: 9
Posted: Tue, 2006-08-01 09:47

Here's a simple phpfile which uses the imageblock to display some random images:

<?php $site_url = "http://yourdomain.com/gallery2/"; ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<table border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><?php @readfile($site_url.'main.php?g2_view=imageblock.External&g2_blocks=randomImage&g2_show=none'); ?></th>
    <td><?php @readfile($site_url.'main.php?g2_view=imageblock.External&g2_blocks=randomImage&g2_show=none'); ?></th>
    <td><?php @readfile($site_url.'main.php?g2_view=imageblock.External&g2_blocks=randomImage&g2_show=none'); ?></th>
    <td><?php @readfile($site_url.'main.php?g2_view=imageblock.External&g2_blocks=randomImage&g2_show=none'); ?></th>
  </tr>
  <tr>
    <td><?php @readfile($site_url.'main.php?g2_view=imageblock.External&g2_blocks=randomImage&g2_show=none'); ?></th>
    <td><?php @readfile($site_url.'main.php?g2_view=imageblock.External&g2_blocks=randomImage&g2_show=none'); ?></td>
    <td><?php @readfile($site_url.'main.php?g2_view=imageblock.External&g2_blocks=randomImage&g2_show=none'); ?></td>
    <td><?php @readfile($site_url.'main.php?g2_view=imageblock.External&g2_blocks=randomImage&g2_show=none'); ?></td>
  </tr>
  <tr>
    <td><?php @readfile($site_url.'main.php?g2_view=imageblock.External&g2_blocks=randomImage&g2_show=none'); ?></th>
    <td><?php @readfile($site_url.'main.php?g2_view=imageblock.External&g2_blocks=randomImage&g2_show=none'); ?></td>
    <td><?php @readfile($site_url.'main.php?g2_view=imageblock.External&g2_blocks=randomImage&g2_show=none'); ?></td>
    <td><?php @readfile($site_url.'main.php?g2_view=imageblock.External&g2_blocks=randomImage&g2_show=none'); ?></td>
  </tr>
</table>

</body>
</html>

Remember to change the $site_url to point at the correct url for your gallery. Also, you have to activate the imageblock module to get this to work.

 
eon03

Joined: 2005-07-18
Posts: 4
Posted: Wed, 2006-08-02 02:36

This string http://www.xoopssite.com/modules/xg2/index.php?g2_view=imageblock.External&g2_blocks=randomImage&g2_show=none

Brings up a random image everytime but I didnt mention that I have Gallery embedded in Xoops and I want to put this code in a custom block. I have the option of a php block or an HTML block and so far either one is giving me blanks. Im going to go try just calling one line of php and see if that works. Look for results in a bit.

Nothing I do seems to work but if run the script outside of my CMS is is perfect. Any ideas?

 
eon03

Joined: 2005-07-18
Posts: 4
Posted: Wed, 2006-08-02 02:36
Quote:
print '<div style="float:left; padding: 0px 0px 0px 2px; width: 150px; text-align: center;">';
@readfile('http://www.xoopssite.com/modules/xg2/index.php?g2_view=imageblock.External&g2_blocks=randomImage&g2_show=none');
print '</div>';
print '<div style="float:left; padding: 0px 0px 0px 2px; width: 150px; text-align: center;">';
@readfile('http://www.xoopssite.com/modules/xg2/index.php?g2_view=imageblock.External&g2_blocks=randomImage&g2_show=none');
print '</div>';
print '<div style="float:left; padding: 0px 0px 0px 2px; width: 150px; text-align: center;">';
@readfile('http://www.xoopssite.com/modules/xg2/index.php?g2_view=imageblock.External&g2_blocks=randomImage&g2_show=none');
print '</div>';
print '<div style="clear:both;">&nbsp;</div>';

This code did it perfectly. Xoops does not like to mix php and HTML in one "block". Thanks for the help.