CB Auto Actions - capturing supplementary information on posting

1 year 8 months ago #330080 by ds-sric-support
I want to trigger a popup upon submitted a new activity, discussion group, blog post, etc. This popup will ask the user for more information to 'tag' the submission, so it needs to be context-aware.

What is the best way to do this?

I tried getting this to work with CB Auto Actions (of Code type) and got so far - but it doesn't seem to work any more - I'm not sure if the issue is around triggers, actions or output. Also I'm not sure whether this approach can work at all with Activity - as that is submitted via Ajax - so would activity_onAfterCreateActivity even trigger?

Thanks

Dave

Please Log in to join the conversation.

1 year 8 months ago #330086 by krileon
Tag the submission with what? You want to add new fields to the activity post? What you're asking for requires extensive custom coding as you'll need to implement the display and store behavior.


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 to join the conversation.

1 year 8 months ago #330088 by ds-sric-support
Hi, thanks for your reply.

Yes I'm prepared for some heavy coding around the tagging itself - I won't be added fields within CB but maintaining a separate data structure.

I just want to get the 'way in' working via CB Auto Actions if possible.

Please Log in to join the conversation.

1 year 8 months ago #330092 by krileon
The only way this is going to work cleanly is to just add new inputs to CB Activity. Using a popup means you're going to have to interrupt the form submit process, which CB Activity is not tested with so you could break the form behavior, but you're welcome to try that approach. As for adding new inputs the following triggers can be used to do this, which is also the triggers you'd use to output your custom JS for the popup.

Edit
$_PLUGINS->trigger( 'activity_onDisplayStreamActivityEdit', array( &$row, &$buttons, $viewer, $stream, $output ) )

New
$_PLUGINS->trigger( 'activity_onDisplayStreamActivityNew', array( &$buttons, $viewer, $stream, $output ) )

Doing a "return" in your auto action with your new inputs should insert them. It does not enforce any HTML structure when doing this so you'll need to either mimic existing HTML of other inputs or create your own however you want it displayed.

As for when to save this information to your external storage you'd use the below.

Validate: Before Update
$_PLUGINS->trigger( 'activity_onBeforeUpdateStreamActivity', array( $stream, $source, &$row, $old ) )

Validate: Before Create
$_PLUGINS->trigger( 'activity_onBeforeCreateStreamActivity', array( $stream, $source, &$row ) )

Save: After Update
$_PLUGINS->trigger( 'activity_onAfterUpdateStreamActivity', array( $stream, $source, $row, $old ) )

Save: After Create
$_PLUGINS->trigger( 'activity_onAfterCreateStreamActivity', array( $stream, $source, $row ) )


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 to join the conversation.

1 year 8 months ago #330097 by ds-sric-support
Thanks. The plan was for the popup to appear after submission rather than interrupt it - being an optional second step for user. So I was trying to render HTML to the page via onAfterCreate... events. I definitely had this working in the past in a simple case with new discussion groups (I'll double check my config), but, as mentioned, the way that Activity is submitted via Ajax seems to prevent any kind of triggering, whether I try javascript or PHP, or just static HTML.

Please Log in to join the conversation.

1 year 8 months ago #330098 by krileon
When new activity is created the ajax responds with the activity container and inserts it into the stream. I've no idea where in this process you plan to implement that beyond doing so entirely with JS.

CB Activity is still using jQuery and has jQuery events for the entire process so that'd probably be how you'd do this if that's what you're wanting to do. All jQuery events are bound to the stream itself so you'd need to listen for save.cbactivity event on the stream root element. The event is as follows.

stream.triggerHandler( 'save.cbactivity', [cbactivity, element, container, newContent, isNew, response] )

You'll need to use the Edit/New triggers described above to add your custom JS to the page or add your custom JS to the page with whatever means you feel are necessary (e.g. insert into your template, etc..).


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 to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.202 seconds

Facebook Twitter LinkedIn