solved Adding view count for Forum threads?

alt=
K_K
@k-k
7 years ago
95 posts
I tried to add a view count for Forum using this as guide:
https://www.jamroom.net/the-jamroom-network/forum/suggestions/42409/item-view-count

...but keep getting an error about the item_id when trying to add this to template:
{jrCore_counter module="jrForum" item_id=$item._item_id name="forum_view"}
updated by @k-k: 05/13/17 10:28:46PM
brian
@brian
7 years ago
10,148 posts
So a forum topic is a collection of items - not a single item. So you need to change the item_id to reference the FIRST post in the topic:

{jrCore_counter module="jrForum" item_id=$items[0]._item_id name="forum_view"}

Let me know if that works for you.


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net

updated by @brian: 02/11/17 08:47:38AM
alt=
K_K
@k-k
7 years ago
95 posts
Thanks for help, I am a total noobie with these :).

I got this error now:
{jrCore_counter} required parameter "_item_id" is missing (modules/jrForum/templates/item_detail.tpl)
michael
@michael
7 years ago
7,715 posts
what that means is there was no number that came in. The error is saying "In order to get you what you are after I need to know the _item_id, but it didn't come in."

So the request is to check that you have the right variable. You need to check that the variable that you are expecting to pass in the _item_id actually contains a number.

So in this case {debug} is what you want. You'd put {debug} in the template just above where your {jrCore_counter.....} is to find out whether $items[0]._item_id contains a number or not.

In this case we know it doesnt because the counter is complaining. So we need to see if the forum's _item_id is there on some other variable.

---
question: what file are you editing?
alt=
K_K
@k-k
7 years ago
95 posts
The forum module's item_detail.tpl
brian
@brian
7 years ago
10,148 posts
Try this:

{jrCore_counter module="jrForum" item_id=$topic._item_id name="forum_view"}



--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
alt=
K_K
@k-k
7 years ago
95 posts
Thanks, that did the trick.