Skip to Content Skip to Menu

[SOLVED] 'Success' message after Auto Action fired from frontend?

  • lousyfool
  • lousyfool
  • OFFLINE
  • Posts: 141
  • Thanks: 46
  • Karma: 5
8 years 7 months ago - 8 years 7 months ago #280772 by lousyfool
Hi,

For certain Auto Actions with trigger set to "None" I'm using links in the frontend to fire them, e.g. in the form of
Code:
<a href="index.php?option=com_comprofiler&view=pluginclass&plugin=cbautoactions&action=action&actions=102&Itemid=129&users=[user_id]">Execute XYZ</a>

This works perfectly fine, but after the Auto Action is executed, an "empty" page appears. Can I have a "success" message on that empty page? Thinking of some HTML output along the lines, "Action done. Please go back to view the updated page." The HTML is not the problem, but where to insert it?

Maybe it's a simple thing to do, but right now my brain is spaghettis and I can't think of a way... :silly:

Thanks for a hint!
Last edit: 8 years 7 months ago by lousyfool.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48541
  • Thanks: 8290
  • Karma: 1445
8 years 7 months ago #280779 by krileon
Yup that's doable with action chaining. You can fire 1 action based off the execution of another. This is done as follows.

Global
Triggers: autoactions_onAction
User: Automatic
Access: Everybody
Conditionals
1: [var2_id] Equal To ACTION_ID_HERE

Where ACTION_ID_HERE is add the id of your first action. You can now redirect, output a message, etc.. after your first action has executed.

For that trigger var1 is the return value of the action (some actions have returns like a Code action), var2 is the action object, var3 is the user object.


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

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

  • lousyfool
  • lousyfool
  • OFFLINE
  • Posts: 141
  • Thanks: 46
  • Karma: 5
8 years 7 months ago - 8 years 7 months ago #280798 by lousyfool
Cool, thanks for the tip!

I've been setting up a "Redirect" Auto Action with parameters as provided by you, and with the ID of the previous (manually triggered) action.

The redirect wants to go back to the 'original page' where the previous action was triggered, plus display a "success" system message. Works, but only if I enter the URL of the 'original page'. If I use "goback" in the URL field, it goes back but doesn't display the system message. "return" leads to what appears like the browser struggling with a loop of redirects before it ends in an error.

Since I have multiple different 'original pages' with manual triggers for different actions which should all end up back at where they started and display the same system message, it'd be even cooler if I could use just that one Redirect Auto Action (with 2 conditions, "greater" and "less" than the relevant IDs).

Question: what to enter in the URL field to make a generic Auto Action valid for more than just one case? Again, "goback" is forgetting the system message...

P.S.:
One more question: any negative effects from this chained Auto Action if the initial one is getting fired not only manually but also by a CRON every now and then? Just asking... haven't tried it yet...
Last edit: 8 years 7 months ago by lousyfool. Reason: P.S. added

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48541
  • Thanks: 8290
  • Karma: 1445
8 years 7 months ago #280812 by krileon
You can't use goback with a message. It's a browser history back. Will add a condition to the message parameters to hide them when goback or reload is used since they can not work with those two usages. Reload will not work in your case as it's just going to endlessly reload the action page.

The only way for you to reliably return is for you include the return URL with your action URL. The best way to do this is base64 encode the URL and send it as &return=BASE64_URL_HERE. Then in your redirect action you can use the below to decode and redirect to it.

[cb:parse function="decode" method="base64"][get_return][/cb:parse]

Note you'll need to enable format functions for the action under parameters.

One more question: any negative effects from this chained Auto Action if the initial one is getting fired not only manually but also by a CRON every now and then? Just asking... haven't tried it yet...

Should be fine.


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

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

  • lousyfool
  • lousyfool
  • OFFLINE
  • Posts: 141
  • Thanks: 46
  • Karma: 5
8 years 7 months ago #280813 by lousyfool
Ha, that's a bunch of more good pointers. Great, many thanks!

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

  • lousyfool
  • lousyfool
  • OFFLINE
  • Posts: 141
  • Thanks: 46
  • Karma: 5
8 years 7 months ago - 8 years 7 months ago #280839 by lousyfool

krileon wrote: The only way for you to reliably return is for you include the return URL with your action URL. The best way to do this is base64 encode the URL and send it as &return=BASE64_URL_HERE. Then in your redirect action you can use the below to decode and redirect to it.

[cb:parse function="decode" method="base64"][get_return][/cb:parse]

Note you'll need to enable format functions for the action under parameters.


Meanwhile I've also found the hint on this parse function on the action edit page, ha.

While the general concept works, something must be wrong with either encoding or decoding. Maybe it's due to me encoding an SEF-friendly relative URL (e.g. "first-part/second-part"), but if I send whatever base64 garbage it's encoded into as &return=, the decoding produces just a different bunch of garbage, but doesn't resolve it to what it was before encoding.

Anyway, what I'm doing now is sending the relative URL as is (in the fashion "&return=first-part/second-part") and using
[cb:parse function="decode" method="url"][get_return][/cb:parse]
in the return action. And it works, so I'm happy :)

Now, if there were only an "OR" option for conditions in Auto Actions - as already asked for in other threads...
Because since I want to use this return action for multiple others, I may be able to utilize "Greater than" and "Less than" to catch some that are within a certain range of action IDs, but as the jungle of actions is growing, this won't work anymore... unless I go into the DB and alter action IDs manually, of course... something you don't want to recommend to anyone who doesn't know exactly what he's doing...


Whatever.
I gotta say at this point, FWIW, that time and time again I'm blown away by Auto Actions - a fantastic, greatly powerful and flexible tool! Seen attempts of providing similar functionality in other extensions, but nothing gets even only remotely close to your Auto Actions! Thank you so much for giving us this extremely helpful gizmo!!!

You've heard it elsewhere, and I can clearly see the workload it would mean, but of course it'd be a dream coming true if there were complete and detailed docs for it rather than the "rudimentary overviews" available.
Meanwhile, I guess we'll keep coming back here from time to time poking you and asking silly questions... ;)
Last edit: 8 years 7 months ago by lousyfool.

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

Moderators: beatnantkrileon
Powered by Kunena Forum