I'm looking for code similar to http://silverstripe.org/general-questions/show/13811
but I'd like to count number of visitors for whole page, so if someone visit Page 1, Page 2 and Page 3 it will be counted as "one visit", and I'd like to diplay this number on every Page.
yes, but the problem is that $Visits variable should be over the Page class, because I want to create site visits couter, not page visits counter. When I put $Visits in Page class it will count only for specific obect of Page class.
public static $db = array(
'ShowInTopMenu' => 'Boolean',
'ShowInLeftMenu' => 'Boolean',
'ShowInLeftMenu2' => 'Boolean',
'visits' => 'Int'
In class Page_Controller
return DB::query("SELECT SUM(visits) FROM page_live")->value();
public function init()
And in template the $totalVisits variable show 0. I think that this line >> $this->visits++; << does not work because in database I noticed that whatever page I display value of visits is always 0.