Hi all, I'm working on counting total views of blog posts but my coding seems to be missing something. Can anyone shed some light on the issue?
$blogs = elgg_get_entities(array('types' => 'object','subtypes' => 'blog', 'limit' => 10, 'owner_guid' => $user_id));
if($blogs){
foreach($blogs as $blog){
$count_annotations = $blog->countAnnotations("blogview");
}}
$total_views = array_sum(array($blogs->$count_annotations));
I'm sure it's something obvious, but I can't see what's not working properly. The output is 0, but on my test site the blog posts do have at least 10 views combined.
EDIT: Sorry I should have mentioned, what I'm trying to do is get the total count of the views for all of his blog posts. So example is below:
Blog post 1 (Views 5)
Blog post 2 (Views 8)
Blog post 3 (Views 12)
Total_views = 25
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by RaĆ¼l Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
- DhrupDeScoop@Dhrup2000
DhrupDeScoop - 0 likes
- Trajan@Trajan
Trajan - 0 likes
- Trajan@Trajan
Trajan - 0 likes
- TahoeBilly@TahoeBilly
TahoeBilly - 0 likes
- Trajan@Trajan
Trajan - 0 likes
- Trajan@Trajan
Trajan - 0 likes
You must log in to post replies.If you're trying to get the number of times the blog post has been viewed (looked at) by users -> this is not stored any where.
Nope, I've already created the annotation called blogviews which is working fine.
The count for each individual blog post is working fine, I'm having trouble combining all the counts together into a total blogviews count for each user of his blog posts.
This is the coding to annotate the blogs:
Would like a profile view counter, do we have one? It shouldn't count your own views...
This is the code taken from profile_counter plugin (provided with old 3column riverdashboard) and the above code does not count your own views.
no one got time?