1770 Posts in 495 Topics by 531 members
Blog Module
SilverStripe Forums » Blog Module » Hit/views counter
Discuss the Blog Module.
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 2083 Views |
-
Hit/views counter

25 July 2009 at 8:04am
I programmed a hit counter for my blog. I always wondered if anyone reads my blog posts ;-) Now I know for sure.
May be this is useful to anyone else.
This is the method (BlogEntry_Controller.php):function incViews() {
if(Session::get('BlogViewed-' . $this->ID) == false){
Session::set('BlogViewed-' . $this->ID, 'true');
$this->Views++;
$SQL_numViews = Convert::raw2sql($this->Views);
DB::query("UPDATE BlogEntry_Live SET Views = '$SQL_numViews' WHERE ID = $this->ID");
}
}
I gets called in the init():function init() {
parent::init();
$this->incViews();
Requirements::themedCSS('blog');
}
I stole this idea from the FORUM-Module. Please tell me what you think about this feature. -
Re: Hit/views counter

25 July 2009 at 11:30pm
I always wondered if anyone reads my blog posts ;-)
Well if you want some better statistics http://www.google.com/analytics/ or any other web statistics package would provide much more useful data.
-
Re: Hit/views counter

25 July 2009 at 11:42pm
Thanks for your hint. I´m not familiar with google analystics yet. It will be my next challenge to work with it.
Obviously my work is useless to others, but I learned some more things about SS.
| 2083 Views | ||
|
Page:
1
|
Go to Top |


