News: TinyPortal Release Schedule. Please read this update for More Info.

Login  |  Register
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media
Welcome, Guest. Please login or register.
Did you miss your activation email?

January 22, 2020, 02:03:36 AM

Login with username, password and session length

Recent

Members
Stats
  • Total Posts: 189421
  • Total Topics: 20795
  • Online Today: 362
  • Online Ever: 917
  • (January 21, 2020, 09:02:26 AM)
Users Online
Users: 1
Guests: 298
Total: 299

Author Topic: Latest and random media from coppermine Blocks  (Read 8754 times)

0 Members and 1 Guest are viewing this topic.

jake1981

  • Guest
Latest and random media from coppermine Blocks
« on: June 18, 2007, 01:07:26 PM »
This has propably been discussed before, but I tried to search it and I didn't find that good explanations, so I made my own and decided to share it with others  :D

Tips
 - To ease up setting this up, please install your coppermine to sub-directory called "gallery" under your tp installation. Other locations will do just fine also, but if you are not experienced with this, you might reach your goal easier by following instructions as they ask you to do. If you are a novice user, I suggest you test this first to brand new installation of smf and tp, by installing coppermine to gallery under root directory.

First, install cpmfetch to your coppermine installation.

What is cpmfetch?
It's a php utility to fetch media from coppermine so it can be displayed on locations outside coppermine. (for e.g. as a block in your tinyportal installation)

How to install it:
 - Download it from http://cpmfetch.fistfullofcode.com/downloads/index.php, latest version is okay (2.0 while writing this)
 - Then extract it to somewhere and copy folder cpmfetch from package to coppermine's directory.
 - Open your browser and point to your coppermine url+"/cpmfetch/install.php", something like this (it depends on the location of your coppermine installation)
Code: [Select]
http://localhost/gallery/cpmfetch/install.php
This would apply if your coppermine would be located on localhost under gallery..
 - It should be installed if you see pictures fetched from your coppermine installation, if something went wrong, check what installer instructs you to do.

Okay, now you should have cpmfetch installed.
So, next we create blocks, use phpboxes.

Latest media
Title: Latest image
Content:
Code: [Select]
echo '<center>';  include_once "./gallery/cpmfetch/cpmfetch.php"; 
  $objCpm = new cpm("./gallery/cpmfetch/cpmfetch_config.php");
  $objCpm->cpm_viewLastAddedMedia(1,1);
  $objCpm->cpm_close();
echo '</center>';

Random media
Title: Random image
Content:
Code: [Select]
echo '<center>';  include_once "./gallery/cpmfetch/cpmfetch.php"; 
  $objCpm = new cpm("./gallery/cpmfetch/cpmfetch_config.php");
  $objCpm->cpm_viewRandomMedia(1,1);
  $objCpm->cpm_close();
echo '</center>';

parameters 1,1 tell how many pictures to display from gallery, first number is amount of columns and second is amount of rows..

That's all. If location of your coppermine is different, change these parts in both blocks:
Code: [Select]
echo '<center>';  include_once "./gallery/cpmfetch/cpmfetch.php"; 
  $objCpm = new cpm("./gallery/cpmfetch/cpmfetch_config.php");

./gallery/ is supposed to be location of your coppermine installation. Remember that this is not supposed to be URL, this is supposed to be location on file-system of server. ( for e.g. c:/htdocs/coppermine or /var/www/htdocs/coppermine )

I posted an ugly screenshot of blocks to here too..
« Last Edit: June 18, 2007, 01:14:59 PM by jake1981 »

JCphotog

  • Guest
Re: Latest and random media from coppermine Blocks
« Reply #1 on: June 27, 2007, 06:12:22 PM »
I just got this working. I'm pleased.  Having the correct location was very important.  Thanks for posting that distinction.  I only wish that it showed the images with in a tiny portal center block when you click on them.

Before I was using an early code snipet to generate a random thumbnail in an html link which directed users to the gallery index with in an iframe using the code found here:
http://www.tinyportal.net/index.php?topic=5246.msg83008#msg83008

jake1981

  • Guest
Re: Latest and random media from coppermine Blocks
« Reply #2 on: June 28, 2007, 07:45:25 AM »
I just got this working. I'm pleased.  Having the correct location was very important.  Thanks for posting that distinction.  I only wish that it showed the images with in a tiny portal center block when you click on them.

Before I was using an early code snipet to generate a random thumbnail in an html link which directed users to the gallery index with in an iframe using the code found here:
http://www.tinyportal.net/index.php?topic=5246.msg83008#msg83008

You can make it to show images on a center block of tinyportal if you want to.
But you need to read guidance of cpmfetch and you need to have knowledge from PHP coding.. Maybe I someday will make that kind of block too when my work doesn't take all my time and if someone hasn't done that yet..

Glad you liked it.

clarkkent93

  • Guest
Re: Latest and random media from coppermine Blocks
« Reply #3 on: July 02, 2007, 04:24:46 PM »
fantastic!!!!!  this was even easier then setting up the integration between coppermine and smf/tp!

fangweile

  • Guest
Re: Latest and random media from coppermine Blocks
« Reply #4 on: July 05, 2007, 02:04:39 AM »
is there any way to display the latest coppermine image in vertical layout instead of horizontal

Offline IchBin™

  • Developer
  • *
  • Posts: 16228
    • My Website
Re: Latest and random media from coppermine Blocks
« Reply #5 on: July 05, 2007, 08:17:36 AM »
You would have to edit the cpfetch file to do that.

jake1981

  • Guest
Re: Latest and random media from coppermine Blocks
« Reply #6 on: July 05, 2007, 01:07:55 PM »
You would have to edit the cpfetch file to do that.

You shouldn't need to.. Change the parameters, 1,1 in block means 1 block in vertical and 1 in horizontal, so 1,2 should show 2 images horizontally and 2,1 would show 2 images vertically if I remember it correctly.. Or did I mis-understand what this was about?

fangweile

  • Guest
Re: Latest and random media from coppermine Blocks
« Reply #7 on: July 06, 2007, 07:07:29 PM »
^that is what I am looking for, it is really work, thanks a lot jake. You are really great.

jacci

  • Guest
Re: Latest and random media from coppermine Blocks
« Reply #8 on: July 09, 2007, 03:43:19 AM »
I tried this, sucessfully got the cpmfetch working, but it is showing this error when i try it in a phpbox

Code: [Select]
Fatal error: Cannot instantiate non-existent class: cpm in /home/pretende/public_html/testsmf/Sources/Load.php(1735) : eval()'d code(35) : eval()'d code on line 2
i copied and pasted the code from jake1981 for the random version, changing my path in both instances

any help greatly appreciated
thanks
jacci


Offline IchBin™

  • Developer
  • *
  • Posts: 16228
    • My Website
Re: Latest and random media from coppermine Blocks
« Reply #9 on: July 09, 2007, 10:57:43 AM »
Sounds to me like the include may have the wrong path if it can't find the class. Check your include path to make sure it is working right and set to the proper path.