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] 2   Go Down

Author Topic: Display Stats  (Read 8542 times)

0 Members and 1 Guest are viewing this topic.

haters

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 36
Display Stats
« on: February 16, 2014, 06:03:45 pm »

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
Logged

haters

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 36
Re: Display Stats
« Reply #1 on: February 28, 2014, 08:00:47 am »

Bumping this. Hopefully someone can help!
Logged

allvip

  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Posts: 1362
Re: Display Stats
« Reply #2 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):
Code: [Select]
<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:

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

ABOUT JQUERY LOAD: https://api.jquery.com/load/
« Last Edit: February 28, 2014, 11:21:31 am by allvip »
Logged

gmc

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 785
    • GMC Design Photo Gallery
Re: Display Stats
« Reply #3 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:
Code: [Select]
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.
Logged
Thanks!
Greg
My Coppermine Gallery
Need a web hosting account? See my gallery for an offer for CPG Forum users.
Send me money

haters

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 36
Re: Display Stats
« Reply #4 on: February 28, 2014, 04:28:10 pm »

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):
Code: [Select]
<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:

Code: [Select]
<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.

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:
Code: [Select]
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!
Logged

allvip

  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Posts: 1362
Re: Display Stats
« Reply #5 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.
Logged

haters

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 36
Re: Display Stats
« Reply #6 on: February 28, 2014, 04:46:46 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.
Logged

gmc

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 785
    • GMC Design Photo Gallery
Re: Display Stats
« Reply #7 on: February 28, 2014, 05:34:30 pm »

Quote
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!
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
Logged
Thanks!
Greg
My Coppermine Gallery
Need a web hosting account? See my gallery for an offer for CPG Forum users.
Send me money

allvip

  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Posts: 1362
Re: Display Stats
« Reply #8 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)

Code: [Select]
<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.

Code: [Select]
#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
« Last Edit: February 28, 2014, 06:23:37 pm by allvip »
Logged

allvip

  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Posts: 1362
Re: Display Stats
« Reply #9 on: February 28, 2014, 06:04:28 pm »

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.
« Last Edit: February 28, 2014, 06:54:45 pm by allvip »
Logged

allvip

  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Posts: 1362
Re: Display Stats
« Reply #10 on: February 28, 2014, 06:06:59 pm »

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
Logged

allvip

  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Posts: 1362
Re: Display Stats
« Reply #11 on: February 28, 2014, 06:11:56 pm »

Sorry for the late response.I had a visit.
« Last Edit: February 28, 2014, 06:44:49 pm by allvip »
Logged

allvip

  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Posts: 1362
Re: Display Stats
« Reply #12 on: February 28, 2014, 06:53:30 pm »

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).
Logged

haters

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 36
Re: Display Stats
« Reply #13 on: February 28, 2014, 07:36:17 pm »

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

Code: [Select]
<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.

Code: [Select]
#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.

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!
Logged

allvip

  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Posts: 1362
Re: Display Stats
« Reply #14 on: February 28, 2014, 07:41:55 pm »

You only have to add :

Code: [Select]
#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
Logged

allvip

  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Posts: 1362
Re: Display Stats
« Reply #15 on: February 28, 2014, 07:44:04 pm »

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

haters

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 36
Re: Display Stats
« Reply #16 on: February 28, 2014, 07:52:18 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!

:(
Logged

allvip

  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Posts: 1362
Re: Display Stats
« Reply #17 on: February 28, 2014, 07:55:38 pm »

Please can I see your website?
Logged

haters

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 36
Re: Display Stats
« Reply #18 on: February 28, 2014, 07:57:26 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.
Logged

allvip

  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Posts: 1362
Re: Display Stats
« Reply #19 on: February 28, 2014, 07:59:36 pm »

allvip.us@gmail.com
Logged
Pages: [1] 2   Go Up
 

Page created in 0.026 seconds with 19 queries.