You are here:  » Count Clicks and Products

Support Forum



Count Clicks and Products

Submitted by dbfcs on Fri, 2006-11-24 09:50 in

In the Admin area, is there any way to create a counter so it adds up the total clicks and total products and displays it at the bottom?

For instance, as the code outputs the feedname and other details, could the number of clicks be added to $totalclicks (which would be defined at the top of the code as 0) and the same for $totalproducts.

Then at the bottom at the end of the feeds, print:

<?php
echo "<p><strong>Essential Statistics</strong><br />Total number of products: ".$totalproducts."<br />";
echo 
"Total number of clicks: ".$totalclicks."</p>";
?>

Submitted by support on Fri, 2006-11-24 10:24

Hi,

Sure - no problem. The two variables you need to use in the loop are:

$feeds[$filename]["product"]
$feeds[$filename]["clicks"]

The loop to display registered feeds starts with:

      if (isset($feeds[$filename]["registered"]))
      {

...so just add the following lines immediately afterwards:

        $totalproducts += $feeds[$filename]["product"];
        $totalclicks += $feeds[$filename]["clicks"];

Hope this helps!
David.

Submitted by Eddie on Sun, 2006-11-26 19:41

David,

This is already on the current version, isnt it ?

Eddie

Submitted by support on Sun, 2006-11-26 20:29

Hi Eddie,

There has never been any summary information; although I think I remember having helped you do a similar mod in the past...

Submitted by Eddie on Mon, 2006-11-27 10:15

David,

OK - I see what you mean. Can youpost the toalt code bloack please anbd confirm where it can /should be added.

Eddie

Submitted by support on Mon, 2006-11-27 17:25

Hi Eddie,

All the code is in this thread - the section at the top (to display the results) goes at the end of admin/index.php, immediately before:

require("admin_footer.php");

The code to increment the counters as indicated in the post (first reply in this thread)...

Cheers,
David.

Submitted by Eddie on Mon, 2006-11-27 18:25

David,

I get:

Essential Statistics
Total number of products: 0
Total number of clicks: 396

Eddie

Submitted by support on Mon, 2006-11-27 18:42

Sorry Eddie - typo, it should be:

        $totalproducts += $feeds[$filename]["products"];
        $totalclicks += $feeds[$filename]["clicks"];

(missed an "s" off the end of products!)

Cheers,
David.

Submitted by Eddie on Mon, 2006-11-27 19:08

David,

Trying to format:

echo "Essential StatisticsTotal number of products: ".$totalproducts."";
echo "Total number of clicks: ".number_format($totalclicks)."";

Submitted by support on Mon, 2006-11-27 19:33

Hi Eddie,

number_format() should work fine in this situation. Are you having trouble getting it to produce the format you want?

Submitted by Eddie on Mon, 2006-11-27 19:39

David,

echo "<p><strong>Essential Statistics</strong><br />Total number of products: ".$totalproducts."<br />";
echo "Total number of clicks: ".number_format($totalclicks)."</p>";

Displays -

Essential Statistics
Total number of products: 132221

Submitted by support on Mon, 2006-11-27 20:00

Hi Eddie,

You don't yet have number_format() around $totalproducts; and you've not included the second line of output - the total number of clicks but I assume that number_format() is working correctly?

Try this:

echo "<p><strong>Essential Statistics</strong><br />Total number of products: ".number_format($totalproducts)."<br />";
echo "Total number of clicks: ".number_format($totalclicks)."</p>";

Cheers,
David.

Submitted by Eddie on Mon, 2006-11-27 20:05

David,

School boy error on my part - all working now.

Eddie

Submitted by dbfcs on Fri, 2006-12-01 12:52

Works like a treat. Many thanks.

By the way:

Essential Statistics
Total number of products: 159,163
Total number of clicks: 179,427

at UK Price Comparison Search in 2 months! Nice!