Jump to content


Gallery Block


  • You cannot reply to this topic
2 replies to this topic

#1 Paul

    Member

  • Members
  • PipPip
  • 16 posts

Posted 22 September 2009 - 02:45 AM

Thanks Gerry for this :-

Quote

<table class='ipb_table' cellspacing="1">
<tbody>
<tr>
<td class='row2'>
<?php
/* Init */
$return = "";
$to_show = 9;
$per_row = 3;
$count = 0;
/* Query */
$this->DB->build( array( 'select' => 'i.id AS picid, i.masked_file_name, i.directory, i.caption',
'from' => array( 'gallery_images' => 'i' ),
'add_join' => array( 0 => array( 'select' => 'm.name as uname',
'from' => array( 'members' => 'm' ),
'where' => 'i.member_id=m.member_id',
'type' => 'left' ) ),
'order' => 'i.id DESC',
'limit' => array( 0, $to_show ),
) );
$this->DB->execute();
/* Got some rows */
if ( $this->DB->getTotalRows() )
{
$return .= "<div><table class='ipb_table'><tr>";
while ( $row = $this->DB->fetch() )
{
$count++;
$return .= <<<EOF
<td class='short'>
<a href="index.php?app=gallery&module=images&section=viewimage&img={$row['picid']}">
<img src="uploads/{$row['directory']}/tn_{$row['masked_file_name']}" alt="{$row['caption']}" />
</a>

Photo submitted by:

<strong>{$row['uname']}</strong>
</td>
EOF;
/* New row */
if ( $count && $count % $per_row == 0 )
{
$return .= "</tr><tr>";
}
}
$return .= "</tr></table></div>";
}
/* Return */
print $return;
?>
</td>
</tr>
</tbody>
</table>



But it doesnt work mate, any ideas

#2 SolidSnke

    Newbie

  • Members
  • Pip
  • 5 posts
  • Gender:Male

Posted 24 September 2009 - 03:30 AM

Yea I am trying to find code that will work for a random image on my ureal portal for IPB 3... so far nothing has worked.. this one looks promising though.

#3 SolidSnke

    Newbie

  • Members
  • Pip
  • 5 posts
  • Gender:Male

Posted 25 September 2009 - 08:38 AM

OK so after trying allot of code here for the random image block on my IPB3 board I could not get any to work. So here is what I did, I wrote my own. Now don't be flamin me saying it poor code and its not efficient. I am not a programmer by heart it is something that I just do from now and then. But it works for me. If you have any questions please feel free to email me at me@solidsnke.com or come by the website and post on the forums your questions. Also this is just version one and I know it does not do a few things, like it bypass's whether the gallery is private or public, but I am working on it. So stay tuned.

<?php

  // Random Gallery Image Block by SolidSnke at www.SolidSnke.com - version 1.1 - me@solidsnke.com
  //
  // This will take the pictures from your IP.Gallery mod and create a thumbnail and post it
  // into a block or whatever your using. I use Unreal Portal and IP.CCS
  // Thanks goes to Pascal Naidon for the vignette.php that makes the thumbnail possible.
  //
  // ** Disclaimer ** I suck at coding so if there is a better way, and I am sure there is
  //                  please dont complain to me. I know this works for me, and as my little brain gets 
  //                  bigger maybe I will update this script.
  //
  //  Installing: upload the vignette.php file to where you want, I put mine in the root folder
  //              to make things simple. If you do put it somewhere else then you will need to 
  //              edit the echo like with the correct web address. Do not change what is after the
  //              ?f= part. That is it, if you should have questions please visit my website 
  //              at http://www.solidsnke.com and check out the forums for help or to ask a question.
  //
  //  Update 1.1: I made some changes to the PHP/mySQL coding and it appears to have fixed the imaging problems
  //              I was having where it was not showing all the pictures and galleries, and its a bit faster.
  //
  //  Copyrights: all copyrights are held by there respectful owners, this script is my intellectual property
  //              but anyone is allowed to use and modify it as they see fit, but it cannot be sold without
  //              direct permission from the creator, which is me.
  //
  // dbConnect string (Server, username to db, userpassword to db)
  $con = mysql_connect("localhost","root_username","root_password");
  if (!$con) {
    die('Could not connect: ' . mysql_error());
  }
  // Selecting the database to connect to
  mysql_select_db("database", $con);
  // this is the mySQL string used to pull from gallery_images (table name)
  
  $offset_result = mysql_query( " SELECT FLOOR(RAND() * COUNT(*)) AS `offset` FROM gallery_images ");
  $offset_row = mysql_fetch_object( $offset_result ); 
  $offset = $offset_row->offset;
  $result = mysql_query( " SELECT * FROM gallery_images LIMIT $offset, 1 " );
  
    while ($row = mysql_fetch_array($result)) {
      // this is the string that will display the thumbnail picture into the block, using the vignette.php.
	  echo "<center><img src='http://www.yourwebsite.com/vignette.php?f=ipb/uploads/".$row['directory']."/".$row['masked_file_name']."'></center>";
    }
  
  mysql_close($con);
?>


Well I cannot upload a file here so if you want the vignette.php file you can hop over and pull it off my board at ==> http://solidsnke.com...om-image-block/

Cheers





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users