CB code autoaction with external file

1 year 7 months ago - 1 year 7 months ago #330767 by activha
CB code autoaction with external file was created by activha
Hi

I don't remember how to access the storing of params in CB Activity table via an external file.

Using an autoaction this is :
$variables['var3']->params()->set( 'location', $newLocation )

but on an external file called by the same autoaction, can I simply use $row->set ? or is it through $action-> ?

On a second topic I read that autoaction now supports $actiondata. Can I use this to transfer the result of an outside php file called in the autoaction to it and use this result in the following lines of the autoaction and how ?

Thanks for the hints

Please Log in to join the conversation.

1 year 7 months ago #330774 by krileon
Replied by krileon on topic CB code autoaction with external file

I don't remember how to access the storing of params in CB Activity table via an external file.

What do you mean by this? You have a Code action with Method set to PHP and you're including your own file? It's no different than if you weren't using a file except you can't use substitutions in your file. Your own topics below have examples already for using CB Activity params storage.

www.joomlapolis.com/forum/developer-members-support/245083-save-to-another-table
www.joomlapolis.com/forum/developer-members-support/244923-cb-autoaction-and-data-attributes

On a second topic I read that autoaction now supports $actiondata. Can I use this to transfer the result of an outside php file called in the autoaction to it and use this result in the following lines of the autoaction and how ?

Action data is used to add additional substitutions while an auto action is executed. Its primary purpose is to pass newly created objects to substitutions for usage in the Output tab. It's not a means of passing it wherever you like.


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 7 months ago #330781 by activha
Replied by activha on topic CB code autoaction with external file
Yes this code works in the code area of the autoaction but not in an external file
I try using the trigger activity_OnAfterCreateStringActivity so the variables is 3 and the activity is retrieved by :
$activ_id = $action->string($user, '[var3_id]');
which works fine but
$variables['var3']->params()->set( 'test', 'test' );
 
That's why I was asking.

Do I have to rebuild the activity object in the php file ?
I also tried 
$variables['var3']->params()->store( 'test', 'test' );
 

Please Log in to join the conversation.

1 year 7 months ago #330783 by krileon
Replied by krileon on topic CB code autoaction with external file
You're using an After trigger. That means it's after the activity was stored. You need to use a Before trigger to add data to the object to be stored. Your code is working fine it's just not storing because wrong trigger.


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 7 months ago #330784 by activha
Replied by activha on topic CB code autoaction with external file
OK thanks, I'll use a DB query to update the fields from the php that's easier

Please Log in to join the conversation.

1 year 7 months ago #330785 by krileon
Replied by krileon on topic CB code autoaction with external file
Then you'd be writing to the database twice for no reason. Why are you needing to do this on the after trigger? Are you needing the activity id? You can also just directly trigger a store yourself instead of writing queries. This is done by just calling ->store() on var3 like how ->params() is called.


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.220 seconds

Facebook Twitter LinkedIn