Skip to Content Skip to Menu

🌟Discover the Joomla AI Plugin that wrote its own story! - CB Editor Assistant 1.1now for Joomla 3, 4 & 5!
✍️ 5-Day Free Trial, then 🎯 save up to 30% with our 🛍️ Intro Offer (First 50 users, ends Dec. 25th)
🌲 Merry Christmas! Great savings on Professional and Developer Memberships! Get 25% off now with code XMAS-2024!

Autoaction id

  • activha
  • activha
  • OFFLINE
  • Posts: 2336
  • Thanks: 117
  • Karma: 13
1 month 1 week ago #339580 by activha
Replied by activha on topic Autoaction id
I'm still hesitant between the two solutions.

1) CB activity seems great because I could get the activity id and store it in another table to check the correct store of data to our IA or not (we add the website data to a vector database)
Also fine is the fact that the autoaction would act on a single post, so it's easy to reuse our old code for CB Gallery without too much changes and depending upon the autoaction id.

On the other hand it seems difficult to get the link consistently from the message. Do you have a substitution for the link only ? or should I parse the full message ? For instance if the user changes the message but not the link the autoaction should not be launched.
Also is it possible to change the activity invite to adapt it to the specific case ? something like What website would you like to add to MoniA ?

So CB Activity seems nicer for the display and the ease of use provided that I could fix the above points 

2) A group field of website field seems less fancy and maybe more robust at first but it seems difficult to iterate to all the data each time and launch the autoaction only for the fields that have been updated or removed.
That would mean that I would need to code another php code to trigger the existing code at each field change because I don't see how to do this easily with the autoaction.
I guess that I could use conditions to check if the fields have been changed.
Are there substitutions to access each website data if I have a form like this ?
Code:
------WebKitFormBoundary4NzSsPCxZAz1GGyW Content-Disposition: form-data; name="_cb_websites_link_group__0__index" 0 ------WebKitFormBoundary4NzSsPCxZAz1GGyW Content-Disposition: form-data; name="_cb_websites_link_group__0__cb_website2" test.org ------WebKitFormBoundary4NzSsPCxZAz1GGyW Content-Disposition: form-data; name="_cb_websites_link_group__0__cb_website2__privacy[]" 0 ------WebKitFormBoundary4NzSsPCxZAz1GGyW Content-Disposition: form-data; name="_cb_websites_link_group__1__index" 1 ------WebKitFormBoundary4NzSsPCxZAz1GGyW Content-Disposition: form-data; name="_cb_websites_link_group__1__cb_website2" test2.org ------WebKitFormBoundary4NzSsPCxZAz1GGyW Content-Disposition: form-data; name="_cb_websites_link_group__1__cb_website2__privacy[]" 0 ------WebKitFormBoundary4NzSsPCxZAz1GGyW Content-Disposition: form-data; name="_cb_websites_link_group__count" 2 ------WebKitFormBoundary4NzSsPCxZAz1GGyW Content-Disposition: form-data; name="cc65f289cc1db5051b3d845ef157d40a" 1 ------WebKitFormBoundary4NzSsPCxZAz1GGyW--


Knowing that for now we use CB Gallery with code autoaction on gallery_onAfterCreateItem and gallery_onAfterUpdateItem which maps these variables...
Code:
$userid = $action->string($user, '[var1_user_id]'); $document = $variables['var1']->path(); $documentName = basename($document); $namefile = pathinfo($variables['var1']->name(), PATHINFO_FILENAME); $olddocumentname = $action->string($user, '[var2_value]'); $olddocument = $variables['var2']->path(); $oldid = $action->string($user, '[var2_id]'); $ext = $variables['var1']->extension(); $link = $variables['var1']->domain(); $id = $action->string($user, '[var1_id]');

... ideally that could be great to use some CB Activity triggers with roughly the same data/variables. 

I may need your advice upon the two solutions and the triggers to use for CB Activity if I can fix the points above.

Thanks for your time.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48616
  • Thanks: 8302
  • Karma: 1446
1 month 1 week ago #339582 by krileon
Replied by krileon on topic Autoaction id

On the other hand it seems difficult to get the link consistently from the message. Do you have a substitution for the link only ? or should I parse the full message ? For instance if the user changes the message but not the link the autoaction should not be launched.

The parser API built into CB Activity can extract URLs. Example as follows.
Code:
$urls = $stream->getParser( $activity->getMessage() )->getLinks();

As you'd be using activity_onAfterCreateStreamActivity you'd have access to both the stream object and activity object to be able to cleanly do this with the above.

Also is it possible to change the activity invite to adapt it to the specific case ? something like What website would you like to add to MoniA ?

I've no idea what an activity invite is.

2) A group field of website field seems less fancy and maybe more robust at first but it seems difficult to iterate to all the data each time and launch the autoaction only for the fields that have been updated or removed.
That would mean that I would need to code another php code to trigger the existing code at each field change because I don't see how to do this easily with the autoaction.
I guess that I could use conditions to check if the fields have been changed.
Are there substitutions to access each website data if I have a form like this ?

It's just JSON data it doesn't really get much easier than that. You're trying to process the POST. Don't process the POST, but access the stored data which will be a JSON string. Example as follows.
Code:
$websites = json_decode( $user->getRaw( 'FIELD_NAME_HERE' ), true );

Now you'd just itinerate through the resulting array. This might also work with substitutions, but am unsure. Example as follows.
Code:
$websites = json_decode( '[FIELD_NAME_HERE]', true );

Are there substitutions to access each website data if I have a form like this ?

Yes, but they're not guaranteed to have a specific index so it maybe difficult trying to access them strictly with substitutions. Field group substitutions usage is explained in the below topic.

www.joomlapolis.com/forum/developer-members-support/246694-how-to-substitute-for-a-field-that-is-part-of-a-field-group


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