forum.coppermine-gallery.net

Support => cpg1.4.x Support => Older/other versions => cpg1.4 cpmFetch by vuud => Topic started by: capecodgal on March 31, 2008, 09:23:25 pm

Title: Cosmetic FAQ's - "How do I make it look like this..."
Post by: capecodgal on March 31, 2008, 09:23:25 pm
First I just wanted to say THANK YOU to Vudd and the rest of the CPG crew for creating such an awsome script.

I have been a CPG user for almost 3 years now and I am in love with CPG & CPMFETCH - it has made my websites much easier to manage the multimedia and then when I found this little treasure (cpmfetch) that Vudd created I knew it would do exactly what I needed.. and so for the past year I have been learning (and fighting) with this script to accomplish pulling content from multiple galleries into my main site and forums. It is amazing that 1 script can do so much rather than installing various mods and hacks to accomplish the same thing and even better I don't need to worry if the new hack will break an old one or vice versa. For those of you looking for the ultimate content syndication mod look no further because you have found it ... now comes the task of learning how to implement it with your website which is where the frustration always lies. (At least it did for me hence why I want to share my knowledge with all of you).

So I have noticed that there are a lot of repeat questions in this section of the board relating to the cosmetic appearance of the displayed images coming from cpmfetch so my goal with this post is to provide a basic tutorial on changing the appearance which will hopefully be useful to fetch newbies and here comes the best part (for the mods)..... which will in turn cut down on the amount of posts in the main cpmfetch board that seem to ask the same questions over and over again about how to customize this script. I will try and update this thread as I become more advanced with my use of the script.

Before I begin... a few things to keep in mind:






Ok so first things first... lets get some content syndication going on the main page of the site. In other words I want to pull my CPG content into the main website which is outside of CPG. The code should look something like this:
Code: [Select]
<?php
 
require_once "./cpg/cpmfetch/cpmfetch.php";
 
$objCpm = new cpm("./cpg/cpmfetch/cpmfetch_config.php");
$objCpm->cpm_viewLastAddedMedia(2,3,$options);
 
$objCpm->cpm_close();
?>

The result should show you the last added media in the gallery in a format of 2 rows of 3 photos per row. Now lets talk about the path for a moment as this was a major issue for me on a few sites. Depending on the setup of your server you will need to adjust the cpg directory to say gallery or photos or whatever you have named your cpg folder. Also the path may need to be adjusted if this example is not working for you. Some paths I have had to use include:
Code: [Select]
./cpg/cpmfetch/cpmfetch.php
or
Code: [Select]
/cpg/cpmfetch/cpmfetch.php
or
Code: [Select]
/home/ftp user/cpg/cpmfetch/cpmfetch.php
or if you are on a Windows server
Code: [Select]
C:\\inetpub\\wwwroot\\website\\cpg\\cpmfetch\\cpmfetch.php


Next lets add some options to the array. Lets say that I want to force the photo to open a new window. I might do this if I were using a frame for the script or if you just want it to open a new window when the image is clicked. The code to add would be:
Code: [Select]
$options = array('windowtarget' => '_blank');
Which would give you...
Code: [Select]
<?php
 
require_once "./cpg/cpmfetch/cpmfetch.php";
 
$objCpm = new cpm("./cpg/cpmfetch/cpmfetch_config.php");
$options = array('windowtarget' => '_blank');
$objCpm->cpm_viewLastAddedMedia(2,3,$options);
 
$objCpm->cpm_close();
?>




Ok so this is getting a bit easier right? Feeling confident enough to try adding in subtitles yet? Here we go.. adding the image views below the thumb...

Code: [Select]
$options = array('windowtarget' => '_blank',"subtitle" => "<center> {{pHits}} Views</center>");
End result being:
Code: [Select]
<?php
 
require_once "./cpg/cpmfetch/cpmfetch.php";
 
$objCpm = new cpm("./cpg/cpmfetch/cpmfetch_config.php");
$options = array('windowtarget' => '_blank',"subtitle" => "<center> {{pHits}} Views</center>");
$objCpm->cpm_viewLastAddedMedia(2,3,$options);
 
$objCpm->cpm_close();
?>





So far so good right? This isn't as painful as you thought  ;D Ok now lets take this a step further and say I only want to display the JPG files in the directory (I do this in my video archives so I don't pull zips onto the main website). The $filter array took me a while to figure out. Essentially you are querying the database for any media with a certain extension and ignoring other media that does not meet that criteria.

Code: [Select]
<?php
 
require_once "./cpg/cpmfetch/cpmfetch.php";
 
$objCpm = new cpm("./cpg/cpmfetch/cpmfetch_config.php");
$objCpm->cpm_setfilter($filter ".jpg");
$options = array('windowtarget' => '_blank',"subtitle" => "<center> {{pHits}} Views</center>");
$objCpm->cpm_viewLastAddedMedia(2,3,$options,$filter);
 
$objCpm->cpm_close();
?>






Ok so now that we have gotten this far, lets talk about the cosmetic appearance of the thumbs. If I wanted to maintain a certain width or height I would add the following to the $options array
Code: [Select]
"imagewidth"=>"100"or
Code: [Select]
"imageheight"=>"100"Resulting in this
Code: [Select]
<?php
 
require_once "./cpg/cpmfetch/cpmfetch.php";
 
$objCpm = new cpm("./cpg/cpmfetch/cpmfetch_config.php");
$objCpm->cpm_setfilter($filter ".jpg");
$options = array('windowtarget' => '_blank',"imagewidth"=>"100","subtitle" => "<center> {{pHits}} Views</center>");
$objCpm->cpm_viewLastAddedMedia(2,3,$options,$filter);
 
$objCpm->cpm_close();
?>



Next step would be controlling the color of the borders or the table where the images are shown. This is all done through a css file and if you are unfamiliar with them you should read up on them first before attempting this. In this example I specified my colors and fonts in my style sheet and am calling the class cpmfetch to load from the style sheet. *** You need to understand css before using this** It may be best to link to the style sheet in your CPG theme or use those values as an example in your new css for the main site; either way this forum is not about css and classes so I am not about to start on all of that in here.

Code: [Select]
<?php
 
require_once "./cpg/cpmfetch/cpmfetch.php";
 
$objCpm = new cpm("./cpg/cpmfetch/cpmfetch_config.php");
$objCpm->cpm_setfilter($filter ".jpg");
$options = array('windowtarget' => '_blank',"imagewidth"=>"100","subtitle" => "<center> {{pHits}} Views</center>","tablestyle" => "cpmfetch");
$objCpm->cpm_viewLastAddedMedia(2,3,$options,$filter);
 
$objCpm->cpm_close();
?>



Ok now lets get a bit more advanced and start talking about statistic displays. You have the ability to pull just about everything except for a member count (if there is a way to do a member count I have not yet found it; instead I used a bridge and grabbed it from my forum). Now I am not talking about subtitles here if you want text below the image display then scroll up a little ways to the 3rd example and reread that part =) that can be accomplsied using view counts, owner names, etc. This section will be about the $format function and how to use it.

As an example I have created a nifty little stats section that I use on the majority of my websites; feel free to use this or modify as needed. There are MANY other values you can use other than the ones I have - read the docs for other examples.

Code: [Select]
Welcome, <b>Guest</b>. <br>
Please  <a href="/cpg/login.php?referer=index.php" target="_blank">Login</a> or <a href="/cpg/register.php" target="_blank">Register</a>
<br>
Total Files: 
$objCpm->cpm_listMediaCount($options);
  <br>
Total Categories:
$objCpm->cpm_formatstats($format = "%c");
$objCpm->cpm_getCategoryCount;
 <br>
Total Albums:
$objCpm->cpm_formatstats($format = "%a");
$objCpm->cpm_getAlbumCount;
<br>
Total Views:
$objCpm->cpm_formatstats($format = "%v");
<br>
Total Comments:
$objCpm->cpm_formatstats($format = "%n");
$objCpm->cpm_getCommentCount;
<br>
Total Members:
(this comes from SMF not CPG as I am using a bridged setup)
Title: Re: Cosmetic FAQ's - "How do I make it look like this..."
Post by: capecodgal on April 04, 2008, 08:42:00 pm
I will add 1 more thing I forgot in the above post - Vudd's site helped me out ALOT when I was first learning the different functions - if you want a basic list of functions you can use then take a look here: http://cpmfetch.fistfullofcode.com/features/index.php (http://cpmfetch.fistfullofcode.com/features/index.php)

Specifically the section labeled: Function to get images or image data back

Once you get the basics and can get the images to display create yourself a basic test page and test out each of the functions and the results they give; you will be surprised how fast you start to pick all of this up  ;D
Title: Re: Cosmetic FAQ's - "How do I make it look like this..."
Post by: vuud on April 14, 2008, 05:28:34 pm

YOU ROCK!

 ;D
Title: Re: Cosmetic FAQ's - "How do I make it look like this..."
Post by: capecodgal on April 15, 2008, 07:18:03 pm
Ahhh cool it got sticked and thank you again Vudd - I figure its the least I could do as I have asked enough questions around here its time I answer some myself LOL!!! :D

I'll add more to this as I get some extra time; anybody have any ideas on what else they want to see some examples on? I am thinking maybe using multiple installs (i.e. 1 photos and 1 videos) as I know alot of the fan sites are set up that way or possibly an example list of the different functions to be used (although I am sure you prefer them to read the docs that)... I'll try to keep it to examples that aren't in the docs to make this more productive
Title: Re: Cosmetic FAQ's - "How do I make it look like this..."
Post by: TechTitan on May 13, 2008, 07:14:54 pm

first and foremost please don't be mad if my example looks silly...  ;)

I only got to know cpmFetch earlier today and being messing with it through out the day... (btw i'm not a programmer so please dont ask anything about php)... just in the spirit of sharing today...  ;D

My example is for SMF + Coppermine (bridged) with SMF default template. I wanted to display last photo additions and some random photos inside SMF info center.

1. Edit ./Themes/default/BoardIndex.template.php

First find:
Code: [Select]
function template_info_center()This is the function SMF use to display the info center. This where recent posts, forum stats, user online are displayed.

For this example I chose to put my Coppermine photos after Recent Posts. But then again the choice is yours.

Find:
Code: [Select]
      // Show lots of posts.
      elseif (!empty($context['latest_posts']))
      {
         echo '
                  <table cellpadding="0" cellspacing="0" width="100%" border="0">';

         /* Each post in latest_posts has:
               board (with an id, name, and link.), topic (the topic's id.), poster (with id, name, and link.),
               subject, short_subject (shortened with...), time, link, and href. */
         foreach ($context['latest_posts'] as $post)
            echo '
                     <tr>
                        <td class="middletext" valign="top"><b>', $post['link'], '</b> ', $txt['by'], ' ', $post['poster']['link'], ' (', $post['board']['link'], ')</td>
                        <td class="middletext" align="right" valign="top" nowrap="nowrap">', $post['time'], '</td>
                     </tr>';
         echo '
                  </table>';
      }
      echo '
               </td>
            </tr>';
   }

Add the following:
Code: [Select]
// Show recent Coppermine uploads
   echo '
            <tr>
               <td class="titlebg" colspan="2">', "Recent Photos", '</td>
            </tr>
            <tr>
               <td class="windowbg" width="20" valign="middle" align="center">
                  <img src="', $settings['images_url'], '/post/xx.gif" alt="Recent Photos" />

               </td>
               <td class="windowbg2" align="center">';
   include "./gallery/cpmfetch/cpmfetch.php";
   $objCpm = new cpm("./gallery/cpmfetch/cpmfetch_config.php");
   $options = array("subtitle" => "Photo by <br>{{pOwner_name}} <br> {{pCtimeFormatted}}", "alttag" => "{{pTitle}}", "subtitlelink" => "./gallery/displayimage.php?album=lastup&cat=0&pos={{aPos}}");
   $objCpm->cpm_viewLastAddedMedia(1, 6, $options);
   //$objCpm->cpm_close();
   echo '
                  </td>';

   // Next some random photos from Coppermine
   echo '
            <tr>
               <td class="titlebg" colspan="2">', "Random Photos", '</td>
            </tr>
            <tr>
               <td class="windowbg" width="20" valign="middle" align="center">
                  <img src="', $settings['images_url'], '/post/xx.gif" alt="Random Photos" />
               </td>
               <td class="windowbg2" align="center">';
    $objCpm = new cpm("./gallery/cpmfetch/cpmfetch_config.php");
    $options = array("subtitle" => "Photo by <br>{{pOwner_name}}<br> {{pCtimeFormatted}}", "alttag" => "{{pTitle}}", "subtitlelink" => "./gallery/displayimage.php?album=lastup&cat=0&pos={{aPos}}");
    $objCpm->cpm_viewRandomMediaFrom("cat=1,2,3,4,5,6,7,8",1, 6, $options);
    $objCpm->cpm_close();
    echo '
                  </td>';

More functions are available at http://cpmfetch.fistfullofcode.com/docs/stable_basic/index.html. Read, learn and then google... 8)