I have a really silly question - but I am struggling with this! It's exactly what I am looking for.
My forum - http://www.alucinae.com/dystopia (phpbb)
I don't use a portal, but I do have a side nav bar, where I really want to display the latest image.
I have tried ssi.php and couldn't get it to work. I thought I'd try this script, and on its own it works great. However, how do I place this script into the TPL file where my side nav is?
If you take a look at the site now - you'll see i have a section for "the galleries" - it is supposed to display the images there.
Any help would be great!
Ok here we go:
In your case create a file e.g 'gallery_side_random_block.php' in you coppermine dir, put the code below in it and change the path to your '/gallery' and correct the connection to your mySql database, further you could change the number of dispayed thumbs with 'LIMIT 0,4' on row 30 to the amount you like. Now there are random 4 thumbs vertically displayed.
<?php
//***Enter Path information here***
//***absolute path to main coppermine directory***
$copperminepath = '/gallery'; //***YOU MUST CHANGE THIS***
//This connects to the mysql DB
//***change username and password below***
$MZrandompic = @mysql_connect('localhost', 'root', ''); //***YOU MUST CHANGE THIS***
if (!$MZrandompic) {
echo( '<p>Unable to connect to the ' .
'database server at this time.</p>' );
exit();
}
//select photo DB
//***YOU MUST CHANGE THIS***
if (! @mysql_select_db('coppermine') ) {
die( '<p>Unable to locate the picture ' .
'database at this time.</p>' );
}
//This gets a random picture record from the database and
//the picture's location and displays it
$MZresult = @mysql_query("SELECT * FROM cpg11d_pictures ORDER BY RAND() LIMIT 0,4");
if (!$MZresult) {
die('<p>Error performing query: ' . mysql_error() .
'</p>');
}
while ( $MZrow = mysql_fetch_array($MZresult) ) {
// $albumid = $MZrow['aid']; //This gets the picture's associated album name
$pos = $MZrow['pid']; //This finds the picture's coppermine location
echo('<P ALIGN=center>');
echo('<a target = "_new" href="' . $copperminepath . '/displayimage.php?album=' . $albumid .
'&pos=-' . $pos . '">'); //make thumbnail clickable
echo('<IMG SRC="' . $copperminepath . '/albums/'); //append base dir structure
echo($MZrow['filepath'].thumb_.$MZrow['filename'] .
'" alt=' . $MZrow['filename'] . ' '. 'border=0 width=80 height=50>' . '</a>'); //outputs path from /userspics
}
//This displays the picture's album name and
//links it to the coppermine album
$MZalbumresult = @mysql_query("SELECT * FROM cpg11d_albums WHERE aid = '$albumid'");
if (!$MZalbumresult) {
die('<p>Error performing query: ' . mysql_error() .
'</p>');
}
while ( $MZalbumname = mysql_fetch_array($MZalbumresult) ) {
echo('<FONT SIZE=1>');
echo('<P ALIGN=center>');
echo('<a href="' . $copperminepath .
'/thumbnails.php?album=' . $albumid . '">' .
$MZalbumname['title'] . '</a>' . '</p>');
}
if (! @mysql_select_db('coppermine') ) {
die( '<p>Unable to reload the main website ' .
'database at this time.</p>' );
}
?>
Go to your sidenav.tpl and add the code below to your table/block 'my gallery' section (change to he right path).
<?php include("/inetpub/coppermine/gallery_side_random_block.php");>
Note: Normally a php-call wil not run from any .tpl inside phpBB so you have to look for the 'eXtreme Styles mod' from
Vjacheslav Trushkin Have success.
For other codefreaks I change the code from zarsky99 to a set of different center-blocks to use within *.tpl they all display horizontally.
1) gallery_center_newest_block.php
<?php
//***Enter Path information here***
//***absolute path to main coppermine directory***
$copperminepath = '/gallery'; //***YOU MUST CHANGE THIS***
//This connects to the mysql DB
//***change username and password below***
$MZrandompic = @mysql_connect('localhost', 'root', ''); //***YOU MUST CHANGE THIS***
if (!$MZrandompic) {
echo( '<p>Unable to connect to the ' .
'database server at this time.</p>' );
exit();
}
//select photo DB
//***YOU MUST CHANGE THIS***
if (! @mysql_select_db('coppermine') ) {
die( '<p>Unable to locate the picture ' .
'database at this time.</p>' );
}
//This gets a random picture record from the database and
//the picture's location and displays it
$MZresult = @mysql_query("SELECT * FROM cpg11d_pictures ORDER BY pid DESC LIMIT 0,6");
if (!$MZresult) {
die('<p>Error performing query: ' . mysql_error() .
'</p>');
}
while ( $MZrow = mysql_fetch_array($MZresult) ) {
// $albumid = $MZrow['aid']; //This gets the picture's associated album name
$pos = $MZrow['pid']; //This finds the picture's coppermine location
// echo('<P ALIGN=center>');
echo('<a target = "_new" href="' . $copperminepath . '/displayimage.php?album=' . $albumid .
'&pos=-' . $pos . '">'); //make thumbnail clickable
echo('<IMG SRC="' . $copperminepath . '/albums/'); //append base dir structure
echo($MZrow['filepath'].thumb_.$MZrow['filename'] .
'" alt=' . $MZrow['filename'] . ' '. 'border=0 width=60 height=50>' . '</a> '); //outputs path from /userspics
}
//This displays the picture's album name and
//links it to the coppermine album
$MZalbumresult = @mysql_query("SELECT * FROM cpg11d_albums WHERE aid = '$albumid'");
if (!$MZalbumresult) {
die('<p>Error performing query: ' . mysql_error() .
'</p>');
}
while ( $MZalbumname = mysql_fetch_array($MZalbumresult) ) {
echo('<FONT SIZE=1>');
echo('<P ALIGN=center>');
echo('<a href="' . $copperminepath .
'/thumbnails.php?album=' . $albumid . '">' .
$MZalbumname['title'] . '</a>' . '</p>');
}
if (! @mysql_select_db('coppermine') ) {
die( '<p>Unable to reload the main website ' .
'database at this time.</p>' );
}
?>
2) gallery_center_random_block.php
<?php
//***Enter Path information here***
//***absolute path to main coppermine directory***
$copperminepath = '/gallery'; //***YOU MUST CHANGE THIS***
//This connects to the mysql DB
//***change username and password below***
$MZrandompic = @mysql_connect('localhost', 'root', ''); //***YOU MUST CHANGE THIS***
if (!$MZrandompic) {
echo( '<p>Unable to connect to the ' .
'database server at this time.</p>' );
exit();
}
//select photo DB
//***YOU MUST CHANGE THIS***
if (! @mysql_select_db('coppermine') ) {
die( '<p>Unable to locate the picture ' .
'database at this time.</p>' );
}
//This gets a random picture record from the database and
//the picture's location and displays it
$MZresult = @mysql_query("SELECT * FROM cpg11d_pictures ORDER BY RAND() LIMIT 0,6");
if (!$MZresult) {
die('<p>Error performing query: ' . mysql_error() .
'</p>');
}
while ( $MZrow = mysql_fetch_array($MZresult) ) {
// $albumid = $MZrow['aid']; //This gets the picture's associated album name
$pos = $MZrow['pid']; //This finds the picture's coppermine location
// echo('<P ALIGN=center>');
echo('<a target = "_new" href="' . $copperminepath . '/displayimage.php?album=' . $albumid .
'&pos=-' . $pos . '">'); //make thumbnail clickable
echo('<IMG SRC="' . $copperminepath . '/albums/'); //append base dir structure
echo($MZrow['filepath'].thumb_.$MZrow['filename'] .
'" alt=' . $MZrow['filename'] . ' '. 'border=0 width=60 height=50>' . '</a> '); //outputs path from /userspics
}
//This displays the picture's album name and
//links it to the coppermine album
$MZalbumresult = @mysql_query("SELECT * FROM cpg11d_albums WHERE aid = '$albumid'");
if (!$MZalbumresult) {
die('<p>Error performing query: ' . mysql_error() .
'</p>');
}
while ( $MZalbumname = mysql_fetch_array($MZalbumresult) ) {
echo('<FONT SIZE=1>');
echo('<P ALIGN=center>');
echo('<a href="' . $copperminepath .
'/thumbnails.php?album=' . $albumid . '">' .
$MZalbumname['title'] . '</a>' . '</p>');
}
if (! @mysql_select_db('coppermine') ) {
die( '<p>Unable to reload the main website ' .
'database at this time.</p>' );
}
?>
gallery_center_toprated_block.php
<?php
//***Enter Path information here***
//***absolute path to main coppermine directory***
$copperminepath = '/gallery'; //***YOU MUST CHANGE THIS***
//This connects to the mysql DB
//***change username and password below***
$MZrandompic = @mysql_connect('localhost', 'root', ''); //***YOU MUST CHANGE THIS***
if (!$MZrandompic) {
echo( '<p>Unable to connect to the ' .
'database server at this time.</p>' );
exit();
}
//select photo DB
//***YOU MUST CHANGE THIS***
if (! @mysql_select_db('coppermine') ) {
die( '<p>Unable to locate the picture ' .
'database at this time.</p>' );
}
//This gets a random picture record from the database and
//the picture's location and displays it
$MZresult = @mysql_query("SELECT * FROM cpg11d_pictures ORDER BY pic_rating desc LIMIT 0,6");
if (!$MZresult) {
die('<p>Error performing query: ' . mysql_error() .
'</p>');
}
while ( $MZrow = mysql_fetch_array($MZresult) ) {
// $albumid = $MZrow['aid']; //This gets the picture's associated album name
$pos = $MZrow['pid']; //This finds the picture's coppermine location
// echo('<P ALIGN=center>');
echo('<a target = "_new" href="' . $copperminepath . '/displayimage.php?album=' . $albumid .
'&pos=-' . $pos . '">'); //make thumbnail clickable
echo('<IMG SRC="' . $copperminepath . '/albums/'); //append base dir structure
echo($MZrow['filepath'].thumb_.$MZrow['filename'] .
'" alt=' . $MZrow['filename'] . ' '. 'border=0 width=60 height=50>' . '</a> '); //outputs path from /userspics
}
//This displays the picture's album name and
//links it to the coppermine album
$MZalbumresult = @mysql_query("SELECT * FROM cpg11d_albums WHERE aid = '$albumid'");
if (!$MZalbumresult) {
die('<p>Error performing query: ' . mysql_error() .
'</p>');
}
while ( $MZalbumname = mysql_fetch_array($MZalbumresult) ) {
echo('<FONT SIZE=1>');
echo('<P ALIGN=center>');
echo('<a href="' . $copperminepath .
'/thumbnails.php?album=' . $albumid . '">' .
$MZalbumname['title'] . '</a>' . '</p>');
}
if (! @mysql_select_db('coppermine') ) {
die( '<p>Unable to reload the main website ' .
'database at this time.</p>' );
}
?>
gallery_center_topview_block.php
<?php
//***Enter Path information here***
//***absolute path to main coppermine directory***
$copperminepath = '/gallery'; //***YOU MUST CHANGE THIS***
//This connects to the mysql DB
//***change username and password below***
$MZrandompic = @mysql_connect('localhost', 'root', ''); //***YOU MUST CHANGE THIS***
if (!$MZrandompic) {
echo( '<p>Unable to connect to the ' .
'database server at this time.</p>' );
exit();
}
//select photo DB
//***YOU MUST CHANGE THIS***
if (! @mysql_select_db('coppermine') ) {
die( '<p>Unable to locate the picture ' .
'database at this time.</p>' );
}
//This gets a random picture record from the database and
//the picture's location and displays it
$MZresult = @mysql_query("SELECT * FROM cpg11d_pictures ORDER BY hits desc LIMIT 0,6");
if (!$MZresult) {
die('<p>Error performing query: ' . mysql_error() .
'</p>');
}
while ( $MZrow = mysql_fetch_array($MZresult) ) {
// $albumid = $MZrow['aid']; //This gets the picture's associated album name
$pos = $MZrow['pid']; //This finds the picture's coppermine location
// echo('<P ALIGN=center>');
echo('<a target = "_new" href="' . $copperminepath . '/displayimage.php?album=' . $albumid .
'&pos=-' . $pos . '">'); //make thumbnail clickable
echo('<IMG SRC="' . $copperminepath . '/albums/'); //append base dir structure
echo($MZrow['filepath'].thumb_.$MZrow['filename'] .
'" alt=' . $MZrow['filename'] . ' '. 'border=0 width=60 height=50>' . '</a> '); //outputs path from /userspics
}
//This displays the picture's album name and
//links it to the coppermine album
$MZalbumresult = @mysql_query("SELECT * FROM cpg11d_albums WHERE aid = '$albumid'");
if (!$MZalbumresult) {
die('<p>Error performing query: ' . mysql_error() .
'</p>');
}
while ( $MZalbumname = mysql_fetch_array($MZalbumresult) ) {
echo('<FONT SIZE=1>');
echo('<P ALIGN=center>');
echo('<a href="' . $copperminepath .
'/thumbnails.php?album=' . $albumid . '">' .
$MZalbumname['title'] . '</a>' . '</p>');
}
if (! @mysql_select_db('coppermine') ) {
die( '<p>Unable to reload the main website ' .
'database at this time.</p>' );
}
?>