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,966
  • Latest: safir45
Stats
  • Total Posts: 195,985
  • Total Topics: 21,321
  • Online today: 814
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 1
  • Guests: 280
  • Total: 281
  • @rjen

Latest and random media from coppermine Blocks

Started by jake1981, June 18, 2007, 08:07:26 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

jake1981

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)

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: 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: 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:
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..

JCphotog

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

Quote from: JCphotog on June 28, 2007, 01:12:22 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

fantastic!!!!!  this was even easier then setting up the integration between coppermine and smf/tp!

fangweile

is there any way to display the latest coppermine image in vertical layout instead of horizontal

IchBin

You would have to edit the cpfetch file to do that.

jake1981

Quote from: IchBinâ„¢ on July 05, 2007, 03:17:36 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

^that is what I am looking for, it is really work, thanks a lot jake. You are really great.

jacci

I tried this, sucessfully got the cpmfetch working, but it is showing this error when i try it in a phpbox

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


IchBin

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.

This website is proudly hosted on Crocweb Cloud Website Hosting.