Skip to Content Skip to Menu

Putting in a bit of competition into CB activity

  • timstohr
  • timstohr
  • OFFLINE
  • Posts: 1091
  • Thanks: 56
  • Karma: 9
5 years 9 months ago #310042 by timstohr
Hi Kyle,
I have a quora-like site for expatriates. I wanted to put in a bit of competition in order to increase user answers. For that I wanted to have a couple of fields in the profile showing how many comments to a certain activity (identifiable by its asset "mainforum") they have made. That should show on their profile (with an associated rank, beginner, knows something, expert, answer master).
Most of all though, I would like to have a module in order to show the person with the highest number of comments or the person with the highest number of activity (again, if possible, only those with a certain asset).

Any possibility to do that?

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48442
  • Thanks: 8276
  • Karma: 1443
5 years 9 months ago #310066 by krileon
Easiest way is probably a Query field using CB Query Field then just query for a count of those comments. Example as follows.

Code:
SELECT COUNT(*) FROM `#__comprofiler_plugin_activity_comments` AS c WHERE c.`user_id` = USER_ID_HERE AND c.`asset` IN ( SELECT CONCAT( 'activity.', a.`id` ) FROM `#__comprofiler_plugin_activity` AS a WHERE a.`asset` = 'ASSET_HERE' )

Ideally this would just have an inner join of the activity to filter things down, but without the object and target columns (not implemented yet) the query is a little odd, but it works if you want to use that method instead.

Code:
SELECT COUNT(*) FROM `#__comprofiler_plugin_activity_comments` AS c INNER JOIN `#__comprofiler_plugin_activity` AS a ON a.`id` = SUBSTRING( c.`asset`, 10 ) AND a.`asset` = 'ASSET_HERE' WHERE c.`user_id` = USER_ID_HERE AND c.`asset` LIKE 'activity.%'


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

  • timstohr
  • timstohr
  • OFFLINE
  • Posts: 1091
  • Thanks: 56
  • Karma: 9
5 years 8 months ago #310286 by timstohr
Hi just got round to testing it out and having some issues.

I think the queries are not right. I am always getting 0 out of either one.

The problem I think is that I have no clue what I should put in USER_ID_HERE (ie what substitution) as I need to have the persons ID on whose field the Query field is on, not the viewers user ID (for that one I can use [user_id])
The other problem is that I am using the asset "mainforum.[user_id]". Here again I would need the ID of the profile that the query field is on.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48442
  • Thanks: 8276
  • Karma: 1443
5 years 8 months ago #310305 by krileon
The queries work fine in my tests. You need to of course replace ASSET_HERE and USER_ID_HERE. Treat all substitutions as strings so replace USER_ID_HERE with '[user_id]' for example. Substitutions in Query and Code fields are always based off the profile owner data.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum