Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
com_connect: How do I reliably detect being on a "thanks_form" page?
I have a signup form mid-way down a page with text above and below and the attribute thanks_form
set to return a success message and a custom response, which is added to the com_connect_labels
and com_connect_values
arrays by a custom plugin after it has done its other work.
Everything works nicely, but when I successfully submit the form, the thanks message shows where the form was … mid-way down the page, which is easy to miss.
My question: Can I detect being on the successful submission “thanks_page” from within my article?
After some faffing around, I got the following working, which detects if the submit button field has been submitted, because that is stored as a $_POST
variable, but it feels a little convoluted and looks like it would also match on a form error page.
<!-- get com_connect_submit $_POST variable from the "submit" button -->
<txp:variable name="form_is_submitted"><txp:page_url type="com_connect_submit" /></txp:variable>
<!-- if no submit button pressed -->
<txp:if_variable name="form_is_submitted" value="">
… Introductory text ...
</txp:if_variable>
<!-- the com_connect form -->
<txp:output_form form="signup_form" />
<!-- if no submit button pressed -->
<txp:if_variable name="form_is_submitted" value="">
... Further text …
</txp:if_variable>
In the process I learned that you get no output without having the com_connect form tag in place on the page, hence the “bracketing out” of the text above and text below the form, rather than an if…else at the top of the page.
PS: I did first tried using redirect="signupsection/"
instead of thanks_form to redirect to another page (note: we need a trailing slash there for txp 4.9), but my custom added strings don’t come through. Not sure if the problem lies with com_connect or my plugin but my suspicion is that it is because there is no com_connect form on the redirected page to “accept” the values.
TXP Builders – finely-crafted code, design and txp
Offline