Extend Core Statistic System

concrete5 comes with a simple statistic system that can keep track of number of visits in your site. If you enabled statistics (Dashboard>System & settings>Statistics), for every page view, concrete will inserts a record into the pageStatistics table. Looking at this table, you see it contains these fields:

cID: visited page id
uID: default=0, user id, if a logged-in user visit the page

At the Dashbord>Reports>Statistics you only can see number of page views in the last 7 days. In this tutorial, I will show you how other reports, that use the inserted data, can be created for the statistic page.


To add a list that show top 10 most popular pages of your site on the statistic page:

1- Tweaking Model: first we add a method to page statisic model. For this copy /concrete/models/page_statistics.php to /models/page_statistics.php. this will override the main file. Now add this method that run a query, get data we need for our report:

public static function getTotalPageViewsByPage() {
     $db = Loader::db();
     return $db->GetAll("select cID,count(pstID) AS num from PageStatistics GROUP BY cID HAVING num>0 ORDER BY num DESC LIMIT 10");

2- Tweaking Controller: copy /concrete/controllers\dashboard/reports/statistics.php to /controllers\dashboard/reports/statistics.php. this will override the main file. Now add this method that get the required data from the method added in previous step:

public function view() {
        $this->set('totalVersions', PageStatistics::getTotalPageVersions());
        $this->set('totalEditMode', PageStatistics::getTotalPagesCheckedOut());
        $this->set('totalPageViewsByPage', PageStatistics::getTotalPageViewsByPage());

Note: this method copied/pasted from /concrete/core/controllers/single_pages/dashboard/reports/statistics.php, I just added last line.

3- Tweaking Single Page: copy /concrete/single_pages/dashboard/reports/statistics.php to /single_pages/dashboard/reports/statistics.php. this will override the main file. Now add this table at the end of the file, befor script tag, that prints data into the statistic single page:



  $value) { $p = Page::getByID($value['cID']); if(!$p->cIsSystemPage){ ?>

Now go to the statistic, you should see a table listing the top 10 popular pages of your site.


Posted by agorujivex on
http://theprettyguineapig.com/prednisone-20-mg/ - Buy Prednisone Prednisone Online http://theprettyguineapig.com/prednisone-20-mg/
Posted by ClarkBoalt on
what erectile dysfunction solution works best
is erectile dysfunction reversible
what does hydroxychloroquine treat
hydrochlorothiazide 12.5 mg
erectile natural diet pdf
plaquenil therapy
tadalafil liquid
tadalafil 40 mg daily
generic name for z pack
buy zithromax cheap
Posted by cheapest erectile disfunction drug on
erectile herbs and vitamins https://erectiledysfunctionpillscvs.com/# does erectile dysfunction mean heart problems
Posted by Betmate on
뱃할맛이 나는곳 먹튀검증 안전한메이져
Posted by Betmate on
먹튀없는업체 먹튀검증 지금바로 접속하세요