Skip to Content Skip to Menu

Post-posting processing of an activity

  • timstohr
  • timstohr
  • OFFLINE
  • Posts: 1091
  • Thanks: 56
  • Karma: 9
3 years 3 weeks ago #326905 by timstohr
Post-posting processing of an activity was created by timstohr
Hi Kyle, how can I make so that in a post processing step I add a title to an activity (that a user put in using the CREATE ACTIVITY HERE field).

The aim is to have an autoaction on OnAfterCreateActivityStream, have as condition "groupjive.group.%.custom.todo" and then somehow add a title in there without loosing the message information (ie what the user has just written).

Here is an idea that just occured to me... we could simply have the above with a Load by and then overwrite it. The problem that I can see is that it will loose all the information regarding the message...

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48541
  • Thanks: 8290
  • Karma: 1445
3 years 3 weeks ago - 3 years 3 weeks ago #326906 by krileon
Replied by krileon on topic Post-posting processing of an activity
Don't used stored titles. They will be removed entirely in CB Activity 6.0.0. You can dynamically add titles using the onDisplayStreamActivity trigger. Example as follows.

Global
Triggers: onDisplayStreamActivity
Type: Code
User: Automatic
Access: Everybody
Conditions
Field: Custom > Value
Custom Value: [var1_asset]
Operator: Is REGEX
Value: /groupjive\.group.\d+\.custom\.todo/
Action
Method: PHP
Code:
Code:
$variables['var2'] = 'My title here!';
Parameters
References: Variable 2

CB Auto Actions allows for substitutions so you could substitute your field in at the time of title override. var2 is the activity title display that displays next to their name. For the activity message you'd use var3.


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: 3 years 3 weeks ago by krileon.

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

  • timstohr
  • timstohr
  • OFFLINE
  • Posts: 1091
  • Thanks: 56
  • Karma: 9
3 years 3 weeks ago #326909 by timstohr
Replied by timstohr on topic Post-posting processing of an activity
Works absolutely perfectly with one caveat.

I cannot seem to be able to translations of it (or at least I am confused on how to do it). I have tried translating the text directly (has created a group task), I have tried $variables = 'has created a group task' (the variables indicated by translation highlighting) as well as the string indicated by translation highlighting.

Am I doing anything wrong?

Also, that trick with onDisplayStream is AMAZING!

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48541
  • Thanks: 8290
  • Karma: 1445
3 years 3 weeks ago #326916 by krileon
Replied by krileon on topic Post-posting processing of an activity
You can run your string through CBs language API to translate it or use the language format function to send a string through translations. For language format function you'll need to enable format functions under the Parameters tab and can also find example of that format function there. As for API usage the below example should work.

Code:
$variables['var2'] = \CBLib\Language\CBTxt::T( 'My title here!' );

You can also just use a language key like the following.

Code:
$variables['var2'] = \CBLib\Language\CBTxt::T( 'LANGUAGE_KEY_HERE' );

You can use both to allow for English fallback. Example as follows.

Code:
$variables['var2'] = \CBLib\Language\CBTxt::T( 'LANGUAGE_KEY_HERE', 'My title here!' );

You can use built in language overrides to translate all 3 usages.


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: activha

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

Moderators: beatnantkrileon
Powered by Kunena Forum