Display Stats Display Stats
 

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

Display Stats

Started by haters, February 16, 2014, 06:03:45 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

haters

Hiya,

Just want to say thank you for the help in my previous threads.

I'm after some instructions on how I can display the amount of images on the a main website.

For example to have it saying:

"We have over *insert number* photos in our gallery"

Thank ya

haters

Bumping this. Hopefully someone can help!

allvip

#2
You can use jquery load function to load anything you want from a page in another page.
Is not a coppermine way,but is the only way I know.

1.add this in the head of the page (the page where you want to show the stats):

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script>
        $(document).ready( function() {
          $( "#showStats" ).load( "http://your_gallery_link/index.php .statlink" );
});
</script>


2.add an empty p tag on the page at the location you want to show the stats <p id="showStats"></p>

this way jquery load will load in p id showStats index.php page just the div statlink.

10 files in 2 albums and 2 categories with 10 comments viewed 4 times


If you already have jquery loding on your website page then you can delete from the code:


<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>


ABOUT JQUERY LOAD: https://api.jquery.com/load/

gmc

If the page you want to display counts on is PHP... And you already have a connection to the database used by Cooperative, a simple SQL statement:
SELECT COUNT ( * ) FROM cpg_pictures
(where cpg_ is replaced by your table prefix) is all you need to get the count...)

If you need more detailed code or to connect to DB, easy to provide... If not on same site, or page isn't PHP - then a different solution is needed.
Thanks!
Greg
My Coppermine Gallery
Need a web hosting account? See my gallery for an offer for CPG Forum users.
Send me money

haters

Quote from: allvip on February 28, 2014, 11:14:50 AM
You can use jquery load function to load anything you want from a page in another page.
Is not a coppermine way,but is the only way I know.

1.add this in the head of the page (the page where you want to show the stats):

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script>
        $(document).ready( function() {
          $( "#showStats" ).load( "http://your_gallery_link/index.php .statlink" );
});
</script>


2.add an empty p tag on the page at the location you want to show the stats <p id="showStats"></p>

this way jquery load will load in p id showStats index.php page just the div statlink.

10 files in 2 albums and 2 categories with 10 comments viewed 4 times


If you already have jquery loding on your website page then you can delete from the code:


<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>


ABOUT JQUERY LOAD: https://api.jquery.com/load/

I tried this, and got it to show but as mentioned in your post it shows the complete stats. I just need the number of photos as the full stats expands out of the text field and messed up my layout.

Quote from: gmc on February 28, 2014, 01:22:42 PM
If the page you want to display counts on is PHP... And you already have a connection to the database used by Cooperative, a simple SQL statement:
SELECT COUNT ( * ) FROM cpg_pictures
(where cpg_ is replaced by your table prefix) is all you need to get the count...)

If you need more detailed code or to connect to DB, easy to provide... If not on same site, or page isn't PHP - then a different solution is needed.
It's on a wordpress page in the header.php file. So the DB connects to wordpress and not CPMG. Not sure exactly where to put that code either!

allvip

gmc solution is better but I will post how to hide with css the words:files in 2 albums and 2 categories with 10 comments viewed 4 times and show only 10

I will work on it now.check after 15 minutes.

haters

Quote from: allvip on February 28, 2014, 04:32:49 PM
gmc solution is better but I will post how to hide with css the words:files in 2 albums and 2 categories with 10 comments viewed 4 times and show only 10

I will work on it now.check after 15 minutes.
Thank ya! Can't wait for it. Can you please possibly add a bold colour for the number in the CSS  that I can edit as well as it comes up bold black which make it look awful on my site.

gmc

QuoteIt's on a wordpress page in the header.php file. So the DB connects to wordpress and not CPMG. Not sure exactly where to put that code either!
If wordpress and CPG are in the same database - just different tables - you can use the Wordpress DB connection (just need their variable that contains the db resource link id...

Or you can connect to the CPG database yourself if it is at least on the same server (or remotely available).
Your CPG file include/config.inc.php has all the info you need to pass to MySQL to connect - and your table prefix for the SQL call.

I haven't worked with Wordpress to know what they do... Does the header code already make database calls?
If you attach the code to a post - I can point you in right direction at least...


(I need to fix my spelling checker on my tablet that keeps changing Coppermine to Cooperative... sigh... thought I caught them all...)

Greg
Thanks!
Greg
My Coppermine Gallery
Need a web hosting account? See my gallery for an offer for CPG Forum users.
Send me money

allvip

#8
This is the html structure of your tag p id showStats (you can see it with firefox inspect element or firebug firefox addon)


<p id="showStats">
  <span class="statlink">
    <strong>980</strong>
      files in
    <strong>88</strong>
    albums and
    <strong>60</strong>
     categories with
    <strong>17</strong>
      comments viewed
    <strong>488</strong>
      times
  </span>
</p>


So you can add to your .css file :

#showStats .statlink strong{display:none;} to hide all the strong tags.
#showStats .statlink strong:first-child{display:block;color:#5A7E9F;font-weight:bold;font-size:100%;line-height:100%;} to show only the first strong tag.

but the words files in,albums and...are not a p tag or any other html tag so you can not give it display:none.
the only think you can do is overflow:hidden; and color transparent to the text:

#showStats {width:5%;height:20px;overflow:hidden;border:1px solid #900;} to give a size to the p tag.this way you can hide with overflow hidden all the content that does not fits in showStats.
#showStats .statlink{color:transparent;}

I added a border to showStats so you can see how much space it takes on the page.Delete it when you done.

This is what you shoud add to your .css file Above I explained to you every ccs rule I used and why.


#showStats {width:5%;height:20px;overflow:hidden;border:1px solid #900;}
#showStats .statlink{color:transparent;}#showStats .statlink strong{display:none;}#showStats .statlink strong:first-child{display:block;color:#5A7E9F;font-weight:bold;font-size:100%;line-height:100%;}


see the attachment to view my result (I have 980 images in my test gallery)

before p id ShowStats you can add We have over and after photos in our gallery

allvip

#9
edit the width and height values with the numbers that fits (same for other values:edit them to fit your page).I used very small values that are fine for my page but maybe to small for you.

use %,em,rem or px (WHATEVER YOU LIKE) for width,fontsize etc. % and rem are responsive.you can use even 150% or 80%.

Go with gmc solution if it works for you.is much better.

allvip

Here you can find all the css rules to add background color,font family etc to your pages.

http://www.w3schools.com/css/

or type css background color in google to find how to write it in your css

allvip

#11
Sorry for the late response.I had a visit.

allvip

If you want me to help you style it the way you want to look and add the words you have in your gallery...just say exaxty how and what you want.

A link to your page to see the structure of your divs is even better if is ok for you.

You can use jquery load to load any div or other tags from a coppermine page in to your wordpress pages and with css you can change the way it looks to look diffrent(not like on the gallery but smaller or with diffrent colors etc).

haters

Quote from: allvip on February 28, 2014, 06:00:05 PM
This is the html structure of your tag p id showStats (you can see it with firefox inspect element or firebug firefox addon)


<p id="showStats">
  <span class="statlink">
    <strong>980</strong>
      files in
    <strong>88</strong>
    albums and
    <strong>60</strong>
     categories with
    <strong>17</strong>
      comments viewed
    <strong>488</strong>
      times
  </span>
</p>


So you can add to your .css file :

#showStats .statlink strong{display:none;} to hide all the strong tags.
#showStats .statlink strong:first-child{display:block;color:#5A7E9F;font-weight:bold;font-size:100%;line-height:100%;} to show only the first strong tag.

but the words files in,albums and...are not a p tag or any other html tag so you can not give it display:none.
the only think you can do is overflow:hidden; and color transparent to the text:

#showStats {width:5%;height:20px;overflow:hidden;border:1px solid #900;} to give a size to the p tag.this way you can hide with overflow hidden all the content that does not fits in showStats.
#showStats .statlink{color:transparent;}

I added a border to showStats so you can see how much space it takes on the page.Delete it when you done.

This is what you shoud add to your .css file Above I explained to you every ccs rule I used and why.


#showStats {width:5%;height:20px;overflow:hidden;border:1px solid #900;}
#showStats .statlink{color:transparent;}#showStats .statlink strong{display:none;}#showStats .statlink strong:first-child{display:block;color:#5A7E9F;font-weight:bold;font-size:100%;line-height:100%;}


see the attachment to view my result (I have 980 images in my test gallery)

before p id ShowStats you can add We have over and after photos in our gallery
Hey man. I tried adding the CSS and updating the p code, however it literally just shows nothing different. Still the same bunch of text and numbers.

Quote from: gmc on February 28, 2014, 05:34:30 PM
If wordpress and CPG are in the same database - just different tables - you can use the Wordpress DB connection (just need their variable that contains the db resource link id...

Or you can connect to the CPG database yourself if it is at least on the same server (or remotely available).
Your CPG file include/config.inc.php has all the info you need to pass to MySQL to connect - and your table prefix for the SQL call.

I haven't worked with Wordpress to know what they do... Does the header code already make database calls?
If you attach the code to a post - I can point you in right direction at least...


(I need to fix my spelling checker on my tablet that keeps changing Coppermine to Cooperative... sigh... thought I caught them all...)

Greg
They run off two different databases with different usernames and passwords, both on localhost as the host though. As for the header.php as far as I can see it doesn't call any SQL connection. WP runs off a config.php file, not sure what .php file pulls it though.


If either if you have an E-Mail I can send you my sites link and are willing to help out, I'd be much appreciative!

allvip

You only have to add :


#showStats {width:5%;height:20px;overflow:hidden;border:1px solid #900;}
#showStats .statlink{color:transparent;}#showStats .statlink strong{display:none;}#showStats .statlink strong:first-child{display:block;color:#5A7E9F;font-weight:bold;font-size:100%;line-height:100%;}


forget about what I wrote above-is just an explanation

allvip

do not update the p code.let it like I sayd in reply#2.

haters

Quote from: allvip on February 28, 2014, 07:44:04 PM
do not update the p code.let it like I sayd in reply#2.
Ok so my code is:

We are home to a gallery with over <p id="showStats"></p> just for you!

with this in the .css:

#showStats {width:5%;height:20px;overflow:hidden;border:1px solid #900;}
#showStats .statlink{color:transparent;}#showStats .statlink strong{display:none;}#showStats .statlink strong:first-child{display:block;color:#5A7E9F;font-weight:bold;font-size:100%;line-height:100%;}

It still shows this though :S:

We are home to a gallery with over
2,401 files in 186 albums and 26 categories with 0 comments viewed 66,790 times

just for you!

:(

allvip

Please can I see your website?

haters

Quote from: allvip on February 28, 2014, 07:55:38 PM
Please can I see your website?
I can't PM you. Do you have an E-Mail I can link it to you? I'd rather not post on here.

allvip