Advanced search  

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]

Pages: [1]   Go Down

Author Topic: Multiple fetches within Wordpress 2.X  (Read 3733 times)

0 Members and 1 Guest are viewing this topic.

Hein Traag

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: nl
  • Offline Offline
  • Gender: Male
  • Posts: 2166
  • A, B, Cpg
    • Personal website - Spintires.nl
Multiple fetches within Wordpress 2.X
« on: October 24, 2007, 03:15:43 pm »

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.

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

« Last Edit: October 25, 2007, 10:14:55 am by Hein »
Logged

Hein Traag

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: nl
  • Offline Offline
  • Gender: Male
  • Posts: 2166
  • A, B, Cpg
    • Personal website - Spintires.nl
Re: Multiple fetches within Wordpress 2.X
« Reply #1 on: October 24, 2007, 03:56:39 pm »

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
« Last Edit: October 24, 2007, 04:14:16 pm by Hein »
Logged

capecodgal

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 123
Re: Multiple fetches within Wordpress 2.X
« Reply #2 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
Logged

Hein Traag

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: nl
  • Offline Offline
  • Gender: Male
  • Posts: 2166
  • A, B, Cpg
    • Personal website - Spintires.nl
Re: Multiple fetches within Wordpress 2.X
« Reply #3 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
?>

Logged
Pages: [1]   Go Up
 

Page created in 0.019 seconds with 20 queries.