TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,963
  • Latest: BiZaJe
Stats
  • Total Posts: 195,917
  • Total Topics: 21,308
  • Online today: 629
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 469
  • Total: 469

Random photos from coppermine

Started by carver, September 22, 2005, 01:32:19 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Gargoyle


bloodynightmare

omg.. i need something like that to have a one rangom image block and one latest 3 images block both from coppermine, but i can't install fetch, i dunno why, ther's a simple code to use in a couple PHP block to have these results?
i can pm who can hel me telling him the name of the directory and whatever else he could need to modify the code to my needs.. please :|

OzButcher

I've installed cpmfetch and looks like it worked during the install.php (I saw the image)

I pasted the supplied code into a PHP block:

<?php
  
include "../gallery/cpmfetch/cpmfetch.php";
  
$objCpm = new cpm();
  
$objCpm->cpm_viewLastAddedMedia(1,4);
  
$objCpm->cpm_close();
?>


but I get php errors.  :(

My directory structure:
\root
\root\bforum (main smf and TP folder)
\root\gallery (main cmg folder)
\root\gallery\cpmfetch (cpmfetch folder)

anyone know what I'm doing wrong here?

G6Cad

If you use a PHP block you must NOT use the php tags <?php ?>   Remove the tags from the code and try again :)

OzButcher

ok thanks for that tip...

I get this error msg "Random Image Error: config file not specified and default not found - did you run the install program?"

any ideas?

G6Cad

Try this instead

include "../cpmfetch/cpmfetch.php";
$objCpm = new cpm('/gallery');

$objCpm->cpm_viewLastAddedMedia (1,8,array("imagesize" => "Thumb","imageheight" => "75","imagewidth" => "75","windowtarget" => "_new","alttag" =>"From Album: %a Added: %w"));
$objCpm->cpm_close();

OzButcher

#136
It didnt work either so I tried to change the url to ../gallery/cpmfetch/cpmfetch.php but no luck either:

Error: config file /gallery specified but was not found.

I'm pointing it to the right director right?

root/gallery/cpmfetch
root/bforum

the script is called within /root/bforum isnt it? so ../gallery/cpmfetch should go back one directory and then enter the gallery/cpmfetch folder?

What does the $objCpm = new cpm('/gallery'); refer to?

bloodynightmare

#137
I did the process showed by Carver but it shows me this:
Parse error: syntax error, unexpected '<' in /home/.lexy/warhammer/warhammer.clans.it/community/Sources/Load.php(1708) : eval()'d code(35) : eval()'d code on line 1

what've i to do?

Greybrow

I converted a bit the code in the first post.
It shows random picture, excluding movies.
Thumbs title is album and picture name.
Clicking on it will point to bigger picture in the gallery.

Just put it in the php block.
Tested on SMF 1.1.1, TP 0.9.7, bridged CPG 1.4.10,

Only thing needed to set is the cpg prefix and gallery path
$gallery_path = "../gallery"; // no slash '/' at the end. Usually "../gallery"
$gallery_prefix = "cpg_"; // cpg mysql tables prefix. Usually "cpg_"

$result = mysql_query("SELECT filename,filepath,aid,pid,title FROM " . $gallery_prefix . "pictures
WHERE approved='YES'
AND (filename LIKE '%.jpg'
OR filename LIKE '%.jpeg'
OR filename LIKE '%.gif'
OR filename LIKE '%.png')
ORDER BY RAND() DESC LIMIT 1");
$row = mysql_fetch_array($result);

mysql_free_result($result);

$filename = 'thumb_' . $row['filename'];
$filepath = $row['filepath'];
$aid = $row['aid'];
$pid = $row['pid'];
$title = $row['title'];

$result = mysql_query("SELECT aid,title FROM " . $gallery_prefix . "albums
WHERE aid = " . $aid);
$row = mysql_fetch_array($result);

mysql_free_result($result);
$album = $row['title'];

echo '<div align="center"><a href="' . $gallery_path . '/displayimage.php?pos=-' . $pid .'"><img src="' . $gallery_path . '/albums/' . $filepath . $filename .'" border="0" title ="' . $album . ' - ' . $title . '"></a><br></div>';

khoking

I am using the codes below for Random photos:

Quoteecho "<CENTER>";
chdir("../gallery/cpmfetch/");
include "cpmfetch.php";                   
$objCpm = new cpm();
$objCpm->cpm_viewRandomMedia(2,1);
$objCpm->cpm_close();
chdir("../../");
echo 'View Gallery';
echo "</center>";

I want to create another block for Latest Photos, using the codes below:

Quoteecho "<CENTER>";
chdir("../gallery/cpmfetch/");
include "cpmfetch.php";                   
$objCpm = new cpm();
$objCpm->cpm_viewLastAddedMedia(1,1);
$objCpm->cpm_close();
chdir("../../");
echo 'View Gallery';
echo "</center>";

However, I can only get one working AT ONE TIME! If I ON/Activate both, then error occurs.

Any idea why and how the codes above should be edited?

My forum is at:

www.PentaxWorld.com

Many thanks!  :up:

This website is proudly hosted on Crocweb Cloud Website Hosting.