Advertisement:

Author Topic: How can i display the average listings per user in the front end homepage ?  (Read 313 times)

d3sign3r

  • Newbie
  • *
  • Posts: 43
HI.
In the Admin Statistics Users' page (Admin -> Statistics -> Users ) there is a widget that displays the average listings per user. How can i add that code in the front end home page ? The only code i found for that is in the admin file users.php that is responible for the users statistics.
Code: [Select]
<?php printf__('%s listings per user'), number_format($item2) ); ?>
but it doesn't work.

I tried it even on some pages of the admin section but also no luck there too! The only page that this code work without problem is in the statistics/users.php page only.

Any help could be very appreciated.



d3sign3r

  • Newbie
  • *
  • Posts: 43
Any idea there? i stuck on this for the last 10 hours !!!!! :(

calinbehtuk

  • Sr. Member
  • ****
  • Posts: 450
Code: [Select]
$item = Stats::newInstance()->items_by_user();

WEBmods

  • Hero Member
  • *****
  • Posts: 937
  • github.com/webmods-croatia/love-osclass/ | patrick
Hello,

As posted by @calinbehtuk, you need to use

Code: [Select]
<?php $item Stats::newInstance()->items_by_user(); ?>.

It returns an array, what interests you is $item[0]['avg'].

So to get the average listings by user rounded to 2 decimals use this code:

Code: [Select]
<?php
$item 
Stats::newInstance()->items_by_user(); // Get stats array.
$average $item[0]['avg']; // Get average items from array.
$average number_format($average2); // Round.
printf__('%s listings per user'), $average ); // Output (with translation).
?>


Regards.

d3sign3r

  • Newbie
  • *
  • Posts: 43
Thank you it worked perfect!