coppermine-gallery.com/forum

Support => cpg1.4.x Support => Older/other versions => cpg1.4 cpmFetch by vuud => Topic started by: adnoctum on November 02, 2006, 05:07:49 PM

Title: Separate latest and random pics...
Post by: adnoctum on November 02, 2006, 05:07:49 PM
First of all, great stuff !

I got it to work on a site, I used this code...


<?php
include "galleri/cpmfetch/cpmfetch.php";
$objCpm = new cpm('/galleri');
$objCpm->cpm_viewLastAddedMedia (2,1,array("imagestyle" => "test1"));
$objCpm->cpm_viewRandomMedia (2,1,array("imagestyle" => "test1"));
$objCpm->cpm_close();
?>



But, I would like to separate "latest added" and "random" from each other, and have random at one place on my mainpage and latest at a different place.I did try to make two php include files out of it, one for latest and one for random.

I get the following error message: "Fatal error: Cannot redeclare class cpm in "LINK TO CPMFETCH.PHP" on line 33.

How can I get it to work ?
Title: Re: Separate latest and random pics...
Post by: vuud on November 02, 2006, 05:15:58 PM

Easy.  You just "reuse" your $objCpm...

Here is how...


<-- This is at the top of your file -->
<?php
include "galleri/cpmfetch/cpmfetch.php";
$objCpm = new cpm('/galleri');
?>


... html, other stuff goes here - whatever

<?php
$objCpm
->cpm_viewLastAddedMedia (2,1,array("imagestyle" => "test1"));
?>


... more html, whatever...

<?php
$objCpm
->cpm_viewRandomMedia (2,1,array("imagestyle" => "test1"));
?>


... more html, whatever...

<!-- this is the bottom of your file -->
<?php
$objCpm
->cpm_close();
?>



You do that as many times as you want, just have one "new" and one "close".