![]() |
![]() |
![]() |
CpmFetch walkthrough | Getting Started with CpmFetch | Upgrading version 1.6.x to 2.0 |
Okay, so that was an easy, not so real-life example. In real life people go crazy and want to put images all over the page. Do you need to repeat all six lines each time? No. In fact, that can cause you problems.
Our example:
<?php include_once "./cpg/cpmfetch/cpmfetch.php"; $objCpm = new cpm("./cpg/cpmfetch/cpmfetch_config.php"); $options = array(?subtitle? => ?File name : {{pFilename}}?); $objCpm->cpm_viewLastAddedMedia(1, 4, $options); $objCpm->cpm_viewRandomMediaFrom(?cat=1?,1, 4, $options); $objCpm->cpm_close(); ?>
Could be broken up like so on a real web page:
<?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(1, 1, $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?, 2, 4); // Line 5 // HTML code and stuff // Here is the bottom of the page, lets close things up $objCpm->cpm_close(); // Line 6 ?>
Database connections take the longest time for most processing. CpmFetch will not make a database connection until it absolutely needs to. Then it will hold it as long as it can.
![]() |
![]() |
![]() |
CpmFetch walkthrough | Getting Started with CpmFetch | Upgrading version 1.6.x to 2.0 |
Documentation generated on Tue, 10 Apr 2007 23:00:31 -0400 by phpDocumentor 1.3.0