list_MediaCount function > count ALL items rather than public-only items list_MediaCount function > count ALL items rather than public-only items
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

list_MediaCount function > count ALL items rather than public-only items

Started by tantley, March 29, 2007, 06:50:33 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

tantley

Using CPG 1.4.10 & cpmFetch 1.6.4

I have groups enabled in CPG; unregistered visitors see a portion of the available images whereas registered can see all.

Currently, I am utilizing Ecto's code for counting items in the cpg_pictures table in MySQL. (See thread)

Using cpmFetch, the list_MediaCount function reports 1,694 items (as this is the number of 'public' images as per the docs).

Is there a method to have cpmFetch dynamically retrieve the total number of ALL categories, regardless of access grouping?

I wish to display that number to visitors in order to encourage registration.

Could not locate any relevant topic with search here or on FistFullOfCode.com that I could understand.

Thanks for this awesome utility. Very powerful and handy to have around!

vuud

Quote from: tantley on March 29, 2007, 06:50:33 PM
Using CPG 1.4.10 & cpmFetch 1.6.4

I have groups enabled in CPG; unregistered visitors see a portion of the available images whereas registered can see all.

Currently, I am utilizing Ecto's code for counting items in the cpg_pictures table in MySQL. (See thread)

Using cpmFetch, the list_MediaCount function reports 1,694 items (as this is the number of 'public' images as per the docs).

Is there a method to have cpmFetch dynamically retrieve the total number of ALL categories, regardless of access grouping?

I wish to display that number to visitors in order to encourage registration.

Could not locate any relevant topic with search here or on FistFullOfCode.com that I could understand.

Thanks for this awesome utility. Very powerful and handy to have around!


Hmmm, one of the functions used to do that, but I think I optimized it into working the way everything else does.

No matter.

To unlock the private images just call

$objCpm->cpm_unlockPrivate(true);

before you call the cpm_listMediaCount()

Mind you that from that point forward, any call will have access to private photos.

Guess how you change it back?

$objCpm->cpm_unlockPrivate(false);


Will that work for you?








Please post for help to the forum... PM me only if you are sending security related items (passwords, security problems, etc).

cpmFetch - Images, RSS feeds from CPG from outside CPG
New release notification signup also. 
See http://cpmfetch.fistfullofco

tantley

After a few hours of working with the code and reading docs, I happened upon the "cpm_Unlock_Private" function. It was referred to as "cpm_unlockPrivate" in the online docs- thus confusing me until I looked directly at the function code in "cpmfetch.php". Once I called the function with the missing "_", it worked properly.

This code, when called with a non-zero value, will allow the count to include ALL items in CPG rather than just public. Also see "cpm_formatStats" for better formatting options.

<?php

include_once "../cpmfetch/cpmfetch.php";

$bool 1;

$objCpm = new cpm('/media_server');
$objCpm->cpm_unlock_Private($bool);
$objCpm->cpm_listMediaCount();
$objCpm->cpm_close();

?>


I always hate it when I find the answer myself- because I search and try multiple things before I ever post. Well, maybe this will help someone else...

tantley

Guess I worked too long on my previous post.

Thanks for the reply, just the same. I'm learning PHP, so this has been quite an adventure.

vuud

Quote from: tantley on March 29, 2007, 08:38:09 PM
Guess I worked too long on my previous post.

Thanks for the reply, just the same. I'm learning PHP, so this has been quite an adventure.

Yeah, the doc's may or may not be correct on that code.  I do know that in CpmFetch 2.0 (which will be the new stable very soon), you will need to unlock it first.  Changes to the backend and all...

Please post for help to the forum... PM me only if you are sending security related items (passwords, security problems, etc).

cpmFetch - Images, RSS feeds from CPG from outside CPG
New release notification signup also. 
See http://cpmfetch.fistfullofco