forum.coppermine-gallery.net

Support => cpg1.4.x Support => Older/other versions => cpg1.4 cpmFetch by vuud => Topic started by: Hein Traag on October 24, 2007, 03:15:43 pm

Title: Multiple fetches within Wordpress 2.X
Post by: Hein Traag on October 24, 2007, 03:15:43 pm
Hi there,

I have been toying with CPMFetch on my own site (www.rondvierkant.nl (http://www.rondvierkant.nl)) and i managed to get it to display a random image from my cpg in the sidebar and that is looking good.

I regularly am going to post on my own blog and most of the times i also have pictures to go with the story. The pictures are stored in cpg (ofcourse) and i want to use cpmfetch to add some random pictures from a certain album to a new post. And again. And again. You get the idea. Now i found this piece of tutorial code but i am unable to implement in such a way that the random sidebar pictures wil work and the random album specific pictures in the posts also work.

Code: [Select]
Our first CpmFetch code

<?php    // This is at the top of your page
  
include_once "./cpg/cpmfetch/cpmfetch.php";  // Line 1
  
$objCpm = new cpm("./cpg/cpmfetch/cpmfetch_config.php"); // Line 2

// HTML code and stuff

// Here is a spot that you want to have the newest image.
  
$options = array(?subtitle? => ?{{pFilename}}?); // Line 3
  
$objCpm->cpm_viewLastAddedMedia(11$options);  // Line 4

// HTML code and stuff

// Here is a spot you want the 8 random images with no subtitle from category 1
  
$objCpm->cpm_viewRandomMediaFrom(?cat=1?, 24);  // Line 5

// HTML code and stuff

// Here is the bottom of the page, lets close things up
  
$objCpm->cpm_close();  // Line 6
?>


But how to implement this code within WordPress ? Which page(s) do i edit to get this working ? I have been trying to add the code that summons up cpmfetch and the close code to several pages but so far without luck. I hope someone can point me in the right direction  ;)

Cheers!
Hein

Title: Re: Multiple fetches within Wordpress 2.X
Post by: Hein Traag on October 24, 2007, 03:56:39 pm
I did find this Widget for WordPress (http://www.wp-plugins-db.org/plugin/cpmfetch-widget/ (http://www.wp-plugins-db.org/plugin/cpmfetch-widget/)) unfortunately i use a theme which is not prepared for widgets (OrangeSky). But i posted the link anyway, might be usefull for others.

If you use the above mentioned widget plugin and your theme is not prepared for using widgets then read this http://automattic.com/code/widgets/themes/ (http://automattic.com/code/widgets/themes/). It wil guide you through the steps to make your theme ready for widgets such as the cpmfetch widget. Then you wil at least be able to use cpmfetch in your sidebar using this widget.

However i am not going to do cpmfetch with this widget, i am more interested in how to get cpmfetch going the manual way. If anyone has a good tip, or maybe a thread that i missed during searching the board, please let me know.

Thanks
Hein
Title: Re: Multiple fetches within Wordpress 2.X
Post by: capecodgal on October 29, 2007, 12:05:07 am
well this probably isn't the "correct way" as I am by no means a coding guru but if the php will not appear via your word press news post then why not embed a iframe and call the php file to load?

what I mean is say for example create a php file called update.php and within that file place your php code then call that page to load via an frame (or similiar) from word press?

I can't test it to be sure that would work but I would imagine it would as the cpmfetch is loading within its own php file  ;D
Title: Re: Multiple fetches within Wordpress 2.X
Post by: Hein Traag on October 29, 2007, 04:22:13 pm
It's an option what you you posted here. But it should be possible to use cpmfetch code multiple times, in multiple posts.

I need to figure out, perhaps with someone more code savvy then me, where to put these two sections of code:

Code: [Select]
<?php    // This is at the top of your page
  
include_once "./cpg/cpmfetch/cpmfetch.php";  // Line 1
  
$objCpm = new cpm("./cpg/cpmfetch/cpmfetch_config.php"); // Line 2

And

Code: [Select]
// Here is the bottom of the page, lets close things up
  $objCpm->cpm_close();  // Line 6
?>