Skip to Content Skip to Menu

CB Activity Display Output Function

  • sysopcrew
  • sysopcrew
  • OFFLINE
  • Posts: 74
  • Thanks: 14
  • Karma: 3
6 years 6 months ago #304064 by sysopcrew
CB Activity Display Output Function was created by sysopcrew
Is it possible to parse the activity stream output with a function before display for one particular Activity field (such as field_id: 255)?

Use case: an external process writes to the activity DB table with asset
Code:
profile.?.field.255
and JSON for the message. The function would parse the JSON, format it, and output the result to the stream. I couldn't figure out which Auto Action trigger might do this, assuming a Code/PHP Auto Action could do it. I tried activity_onDisplayStreamActivity.

--
David Riviera

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48444
  • Thanks: 8279
  • Karma: 1443
6 years 6 months ago - 6 years 6 months ago #304074 by krileon
Replied by krileon on topic CB Activity Display Output Function
Yes, that's exactly what GJ and CB Gallery are doing for their activity and most of the core activity. You've 2 options basically. 1 is to create a new CB Activity template by copying the default template folder below.

/components/com_comprofiler/plugin/user/plug_cbactivity/templates/default

Next rename your copy to something like "custom". Now delete every file in it except "activity_core.php". Now you can add your own custom core activity parsing code to it as needed.

The other option is to do what GJ and CB Gallery are doing and act on the activity_onDisplayStreamActivity trigger (either in your own custom plugin or CB Auto Actions), which is as follows.

Code:
$_PLUGINS->trigger( 'activity_onDisplayStreamActivity', array( &$row, &$title, &$date, &$message, &$insert, &$footer, &$menu, $stream, $output ) )

Notice most of the variables are references. They allow you to modify the message of an activity, insert new content below the message, next to the date, replace the title, or even alter the activity object variables and more.

If you do this from CB Auto Actions you will need to use a Code action then set Method to PHP. Next under Parameters within your auto action be sure to set Reference Variables to pass references for whatever variables in the above trigger you want to modify. Now you'll be able to modify them in your code with $variables (e.g. $variables would be the $message variable). As for knowing what activity entry to do this on you'd just condition against [var1_asset] under the Conditions of your auto action.


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.
Last edit: 6 years 6 months ago by krileon.
The following user(s) said Thank You: sysopcrew

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

  • sysopcrew
  • sysopcrew
  • OFFLINE
  • Posts: 74
  • Thanks: 14
  • Karma: 3
6 years 5 months ago #304320 by sysopcrew
Replied by sysopcrew on topic CB Activity Display Output Function
This Auto Action is a thing of beauty and exactly what I was wanting. We use CB as a vendor application for an annual gifts fair. Vendors complete their profile at their own pace, and when the Profile Progress gets to 100%, they get the option to pay. After the fair, we archive important data to an activity stream (multiple streams for various bits of data). This now lets me keep data in a semi-workable format (JSON) yet friendly display. I'm not building up #__comprofiler columns for each year.

--
David Riviera
The following user(s) said Thank You: krileon

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

Moderators: beatnantkrileon
Powered by Kunena Forum