Skip to Content Skip to Menu

CB Activity: Filter comments by custom param

  • mlilge
  • mlilge
  • OFFLINE
  • Posts: 13
  • Thanks: 0
  • Karma: 0
3 years 7 months ago #324177 by mlilge
Hi,

I'm using CB Activity just for the comments. Depending on an user's profile setting I like to have this date (an integer) automatically added to the comments he is posting and to present only those comments to him that match his profile setting.

My idea is to add this date to the params array when creating a new comment and use it for a filter when fetching matching comments.

Not sure whether this is a good approach, but I think I can easily update the params array by an AA "activity_onAfterCreateComment" and maybe do the filtering on a AA "activity_onLoadActivityStream".

The maybe cleaner solution would be to automatically create tag-entries in the other plugin table but this appears a bit over-engineered to me.

Would be great if someone could confirm this approach feasible or advise any better solution!

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

  • krileon
  • krileon
  • OFFLINE
  • Posts: 48541
  • Thanks: 8290
  • Karma: 1445
3 years 7 months ago #324186 by krileon
Replied by krileon on topic CB Activity: Filter comments by custom param
There is no support for filtering on parameters. To filter it needs to be able to query on that information for it to be efficient database wise. What is this date supposed to be doing exactly? Comments already log their date. It maybe better to just add that information to the Asset, which you can filter on with the built in filtering functionality. Example as follows for a custom asset in a comment field.

profile.[user_id].field.[field_id].[cb_mydate],profile.[user_id].field.[field_id].%,profile.[user_id].field.[field_id]

The first asset on a stream is always used for storage. So it'd always store with the value of the field cb_mydate added to it. The following assets would be sure it shows all comments regardless of the cb_mydate value and then also without cb_mydate entirely. You'd then just add a filter to the comment stream on the following asset.

profile.[user_id].field.[field_id].[cb_mydate]

If cb_mydate may not exist for the user you'll want to add an IF condition like the following to only use this behavior if it exists.

profile.[user_id].field.[field_id][cb:if cb_mydate!=""].[cb_mydate],profile.[user_id].field.[field_id].%,profile.[user_id].field.[field_id][/cb:if]

You won't need any special custom code for this solution and should just work. You don't have to use a comment field specific asset either. For example the below is entirely with a custom asset that's also user specific.

Asset:
comments.[user_id][cb_mydate],comments.[user_id].%,comments.[user_id]

Asset with IF:
comments.[user_id][cb:if cb_mydate!=""].[cb_mydate],comments.[user_id].%,comments.[user_id][/cb:if]

Filter Asset:
comments.[user_id].[cb_mydate]


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.
The following user(s) said Thank You: mlilge

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

  • mlilge
  • mlilge
  • OFFLINE
  • Posts: 13
  • Thanks: 0
  • Karma: 0
3 years 7 months ago #324194 by mlilge
Hmm, I start to understand better what assets are good for. Still a bit difficult. Is there any documentation about this in addition to the quick help on the modules asset field?

An simple explanation of my need is that registered users can comment on multiple but separated topics. An user can switch between topics through an update to his profile that holds the id of the selected topic in a custom field.

Any user can read all posted comments on a certain topic and just this one (when he has switched to it), regardless whether he has posted any on its own.

I like to have a single activity module that displays all comments posted on a certain topic once the has switched to it.

So, I would never filter for the comments of a certain user, just the topic id is relevant.

Would that mean that have to set up a custom asset like 'field.[field_id].[cb_topic]' where 'field_id' is the id of my custom 'cb_topic' field? cb_topic will get substituted with the actual value of an user's profile setting?

Or do I misunderstood you?

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

  • mlilge
  • mlilge
  • OFFLINE
  • Posts: 13
  • Thanks: 0
  • Karma: 0
3 years 7 months ago #324196 by mlilge
I just added this asset in the format I mentioned and it does exactly what I want it to do!

DB stored assets start with 'field.[id].[value]' and do not hold any profile data. If that format is OK with you, Kyle, I'm more than satisfied.

I'd appreciate a link to good documentation, if available, to stop me asking questions that are answered somewhere else.

Many Thanks for the explanations and hints!

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

  • krileon
  • krileon
  • OFFLINE
  • Posts: 48541
  • Thanks: 8290
  • Karma: 1445
3 years 7 months ago #324200 by krileon
Replied by krileon on topic CB Activity: Filter comments by custom param

Hmm, I start to understand better what assets are good for. Still a bit difficult. Is there any documentation about this in addition to the quick help on the modules asset field?

The parameter includes several examples in addition to my explanation and examples above.

An simple explanation of my need is that registered users can comment on multiple but separated topics. An user can switch between topics through an update to his profile that holds the id of the selected topic in a custom field.

Any user can read all posted comments on a certain topic and just this one (when he has switched to it), regardless whether he has posted any on its own.

Then you should just need the following asset usage.

topic.[cb_topic]

The cb_topic field would hold the topic id.

I like to have a single activity module that displays all comments posted on a certain topic once the has switched to it.

That's doable with a module using the following asset.

topic.TOPIC_ID_HERE

Would that mean that have to set up a custom asset like 'field.[field_id].[cb_topic]' where 'field_id' is the id of my custom 'cb_topic' field?

Doesn't sound like you need it to be field or user specific so my above topic example should be all you need.

cb_topic will get substituted with the actual value of an user's profile setting?

Yes, since assets support substitutions.

I'd appreciate a link to good documentation, if available, to stop me asking questions that are answered somewhere else.

There's no documentation for this. Feel free to post whatever questions you may have here. Unfortunately our documentation for plugins is somewhat lacking as we're a small team and just haven't found the time to pause development to focus on documentation. We'll be exploring better options on how we can generate documentation automatically or at least partially automatically to try and help with this sometime in the future.


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