Random Picture from Coppermine Gallery Block

Forum rules
This forum is not for support requests.

Only post Modifications for Board3 Portal 1.0.x in this forum.
Locked

Topic author
Fliggerty
Active Member
Posts: 12
Joined: 14. July 2008 04:31

Random Picture from Coppermine Gallery Block

Post by Fliggerty »

Hello,

This is a simple block I put together so I could have a "pic of the moment" thing on my portal. It randomly pulls an image from my Coppermine gallery and displays it in the block.

I came across the Coppermine part of the code on the forum there.

First, make a file called get_photo.php in /root/coppermine (or wherever you gallery is installed.)

Code: Select all

<?php 
// ------------------------------------------------------------------------- //
// Coppermine Photo Gallery - RSS Feed                                      //
// ------------------------------------------------------------------------- //
// Copyright (C) Dr. Tarique Sani                                           //
// http://tariquesani.net/                                                  //
// Adapted by djib to display a random photo - http://djib.biz              //
// This program is free software; you can redistribute it and/or modify     //
// it under the terms of the GNU General Public License as published by     //
// the Free Software Foundation; either version 2 of the License, or        //
// (at your option) any later version.                                      //
// ------------------------------------------------------------------------- //
// Just put into the same directory as your coppermine installation         //
// ------------------------------------------------------------------------ //

define('IN_COPPERMINE', true);
define('INDEX_PHP', true);
require('include/init.inc.php');

//How many items you want to show in your get_photo script
if(isset($_GET['nb'])) {
     $thumb_per_page=$_GET['nb'];
} else {
     $thumb_per_page = 1;
}
$thumb_count = 1;
$lower_limit = 0;

if(isset($_GET['album'])){
    $album = $_GET['album'];
}

//If it is a numeric album get the name and set variables
if ((is_numeric($album))){
     $album_name_keyword = get_album_name($album);
     $CURRENT_CAT_NAME = $album_name_keyword['title'];
     $ALBUM_SET = "AND aid IN (".(int)$_GET['album'].")".$ALBUM_SET;
     //Set the album to last uploaded
     $album = 'random';
}

//If the album is not set set it to lastup - this is the default
if(!isset($album)){
     $album = 'random';
}


//Changes these to point to your site if the following is not giving correct results.
$link_url = $CONFIG['ecards_more_pic_target']."displayimage.php?pos=-";
$image_url = $CONFIG['ecards_more_pic_target']."albums/";


$data = get_pic_data($album, $thumb_count, $album_name, $lower_limit, $thumb_per_page);


foreach($data AS $picture) {
    $thumb_url = "$image_url$picture[filepath]$CONFIG[thumb_pfx]$picture[filename]";
    $description = '<a href="' . $link_url . $picture['pid'] . '" target="_blank"><img src="' . $thumb_url . '"  border="0"/></a>';
    echo $description;

}
?
Then I made a new block template called random_shot.html:

Code: Select all

<div class="forabg2">
   <div class="inner">
      <span class="corners-top"><span></span></span>
      	<ul class="topiclist">
			<h3>Screenshot</h3>
		</ul>
		<ul class="topiclist forums">
         	<iframe src="http://www.fliggerty.com/coppermine/get_photo.php" align="center" border="0" width="120" height="120" frameborder="0"></iframe>		
		</ul>
      <span class="corners-bottom"><span></span></span>
   </div>
</div>
<br style="clear:both" />
You might want to change forabg2 to a class that really exists in your css.

Next, edit portal_body.html and add this where you want the block to show up:

Code: Select all

		<!-- INCLUDE portal/block/random_shot.html -->
And that's it.

I hope someone else can find this to be a useful thing!

--Fligg
User avatar

thomas.d
Former Team Member
Posts: 625
Joined: 19. January 2008 23:56
phpBB.de User: thomas.d
phpBB.com User: thomas.d
Contact:

Re: Random Picture from Coppermine Gallery Block

Post by thomas.d »

Hi Fligg,

thanks for sharing!
Viele Grüße

Thomas

Deutsche Sprachdateien für
[Alpha] phpBB Calendar 0.0.8 (alightner) | [RC] phpBB Arcade 1.0.RC8 |
ACP Add User MOD 1.0.0 |
Locked

Return to “board3 Portal v1.0.x - Modifications in Dev”