Multiple fetches within Wordpress 2.X Multiple fetches within Wordpress 2.X
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

Multiple fetches within Wordpress 2.X

Started by Hein Traag, October 24, 2007, 03:15:43 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Hein Traag

Hi there,

I have been toying with CPMFetch on my own site (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.

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


Hein Traag

#1
I did find this Widget for WordPress (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/. 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

capecodgal

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

Hein Traag

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:

<?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

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