With auto action get article id from trigger onContentAfterSave

5 months 3 weeks ago - 5 months 2 weeks ago #335978 by rbuelund
I would like to automatically unpublish articles after a registered user has edited his own article. I am trying to use Auto Action with code - but I need the article ID from the trigger - is that possibel to retrieve  ?

Please Log in to join the conversation.

5 months 3 weeks ago #335979 by krileon
That's possible. What Joomla event are you trying to use? You should be able to use Joomla content events and have access to all the data it provides, which includes the full article object. Joomla content event documentation is as follows.

docs.joomla.org/Plugin/Events/Content

So for example onContentAfterSave would work. Condition against the context to be sure it's an article (believe this should be com_content.article) and against isNew to make sure it's an edit and not newly created. It would then run whatever code you've supplied in your code 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.

Please Log in to join the conversation.

5 months 3 weeks ago - 5 months 3 weeks ago #335980 by rbuelund
I am trying to use onContentAfterSave, but I do not know what variables to use to get eg the article object in the code field ?

Please Log in to join the conversation.

5 months 3 weeks ago #335988 by krileon
See the above documentation. The variables are listed there. CB Auto Action provides them in order as var1, var2, var3, etc.. The variables for onContentAfterSave are as follows.

var1 = context
var2 = article
var3 = isNew


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.

5 months 3 weeks ago - 5 months 3 weeks ago #335990 by rbuelund
So do I understand you correct: To get the articleId of the article that triggered the event i use this in the code field in the auto action ?

$articleId = [var2]->id;

Please Log in to join the conversation.

5 months 3 weeks ago #335995 by krileon
You can't access substitutions like objects. They're always array keys. So you'd use [var2_id] to access the article id.


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

Facebook Twitter LinkedIn