Page Hit Counter Concrete 5.7
PermalinkIs this fairly easy to achieve or can someone produce a block for this.
My site is internal so I don't know whether Google analytics would be suitable. So there's no simple way to count every visit to a page (doesn't have to be unique really just a simple page counter)
I need a basic page counter for some projects I am working on. I've been given some advice on how to make something light that should do the job. When it is done I will put it in the marketplace.
Are your internal users logged in?
That is the goal of what I am making, something to purely record page information and views, then update a table by one.
The rest would be excluding admins and logged in users, but that should be configurable.
did manage to find a solution?
Just create number attribute "page_count". Sign it to page type you'd like to count. Include this code somewhere in a page template.
<?php $c = Page::getCurrentPage(); $cp = new Permissions($c); $c = Page::getCurrentPage(); $page_count=$c->getAttribute('page_count'); if (!$cp->canAdminPage()) { $c->setAttribute('page_count', $page_count+1); } ?> <div><?php if ($cp->canAdminPage()) { echo 'This page was viewed '.$page_count.' time(s).'; } ?></div>
If you want sort block PageList by most viewed pages you have to extend PageList's controller or make single page with custom page list.
switch ($orderBy) { case 'chrono_asc': $this->pl->sortByPublicDate(); break; case 'most_popular': $this->pl->sortBy('ak_page_count', 'desc'); break; default: $this->pl->sortByPublicDateDescending(); break; }
Modified your code and made a FREE package for the marketplace.
Also works with v8, see attached.
However, I couldn't get the pagelist sorting to work, I did all possible ways...
Can you help providing me the full controller.php for most popular PageList sorting?
Running version 8.0.1
Thanks in advance
You're welcome to use it, however there is no support. See attached.
If you are looking for detailed statistics, I would recommend setting up a Google Analytics account.
https://www.google.com/analytics/...
This block looks fairly complex and would require a substantial investment in time to recreate for 5.7.