Welcome Guest, Not a member yet? Register   Sign In
Post view count in codeigniter blog
#3

[eluser]boltsabre[/eluser]
Okay, so if you have your blog already up and going it's real easy.

In your "view post" controller function, before you get the blog post details from your DB like you normally do. Then simply call a new model function that increments "view_count" for that blog. Then get your blog post details and it will have the correct count.

One line of code in your controller, one new small model function (max 8 lines of code, plus function comments).

Obviously you'll need to create a new DB column (view_count) in your blog post table.

Things get a bit more tricky if you don't wan't the count to increment if admin/author views the post, but even that's not too bad.

Post some code if your stuck.


Messages In This Thread
Post view count in codeigniter blog - by El Forum - 02-03-2014, 04:26 AM
Post view count in codeigniter blog - by El Forum - 02-04-2014, 02:05 AM
Post view count in codeigniter blog - by El Forum - 02-04-2014, 05:50 AM



Theme © iAndrew 2016 - Forum software by © MyBB