TinyPortal

Development => Support => Topic started by: scott_t on June 21, 2009, 10:59:16 PM

Title: 2 blocks with cpmfetch?
Post by: scott_t on June 21, 2009, 10:59:16 PM
Thanks to ZarPrime, I now have my coppermine block working via cpmfetch. My only additional question is if it is possible to have 2 cpmfetch blocks? What I'd like to do is have the one existing gallery with random images which works, then a second block with images from another gallery under that block.

The problem I have is with the exact same code that is working in block #1

include "../SCTNBLTCOPPER/cpmfetch/cpmfetch.php";
 $objCpm = new cpm("../SCTNBLTCOPPER/cpmfetch/cpmfetch_config.php");
 $objCpm->cpm_viewRandomMedia(1,6);
 $objCpm->cpm_close();


Gives me an error in block # 2:
Fatal error: Cannot redeclare class cpm in /homepages/9/d139621264/htdocs/SCTNBLTCOPPER/cpmfetch/cpmfetch.php on line 50

So really I have 2 questions here..

1. Can cpmfetch handle more then 1 block?
2. Can I direct cpmfetch to a specific album, not the general public album #1?

Thanks,

Scott
Title: Re: 2 blocks with cpmfetch?
Post by: IchBin on June 22, 2009, 02:59:43 AM
Since you are calling the code twice, you should instead use require_once() instead of include().

Try changing this line:
include "../SCTNBLTCOPPER/cpmfetch/cpmfetch.php";

To this:
require_once("../SCTNBLTCOPPER/cpmfetch/cpmfetch.php");
Title: Re: 2 blocks with cpmfetch?
Post by: scott_t on June 22, 2009, 03:01:04 PM
Worked like a charm Ichbin. Appreciated. Now all I need to do is test code for using a specific album, not all public albums. So I will have 2 cpmfetch blocks.

1. One showing random public gallery images from coppermine
2. Another showing public images from a different album and only that album.

For item # 2 this is the code I am planning on trying...

<?php
require_once "./gallery/cpmfetch/cpmfetch.php";
$objCpm = new cpm("./gallery/cpmfetch/cpmfetch_config.php");
$objCpm->cpm_setfilter($filter ".jpg");
$options = array('windowtarget' => '_top',"imagewidth"=>"130","subtitle" => "<center></center>","tablestyle" => "cpmfetch");
$objCpm->cpm_viewRandomMediaFrom ("album=4"16$options);
$objCpm->cpm_close();
?>


Additional question. In the code of the block, do I need to include the <?php tag?
Title: Re: 2 blocks with cpmfetch?
Post by: IchBin on June 22, 2009, 03:37:58 PM
<?php or ?> tags cannot be used in a block.
Title: Re: 2 blocks with cpmfetch?
Post by: scott_t on June 22, 2009, 08:52:46 PM
All set, works like a charm...Thanks...

ST