Forum
On form submit, via blog post, URL format changes
Hi
I am adding a mailchimp form to my blog posts, when I click the submit button, on form submit, it changes the URL format.
URL format is: https://website.uk/blog/2016-10-16-blog-post-name/
After submit button is pressed: https://website.uk/blog/post.php?s=2016-12-09-adding-svg-icons-to-a-sprite-with-perch-cms
Any idea what I have done wrong?
Diagnostic Report
Perch: 2.8.32, PHP: 5.5.38, MySQL: mysqlnd 5.0.11-dev - 20120503 - $Id: 15d5c781cfcad91193dceae1d2cdd127674ddb3e $, with PDO
Server OS: Linux, cgi-fcgi
Installed apps: content (2.8.32), assets (2.8.32), categories (2.8.32), perch_blog (5.0), perch_forms (1.8.3), perch_mailchimp (3.0.1)
App runtimes: <?php $apps_list = array( 'content', 'categories', 'perch_forms', 'perch_blog', 'perch_mailchimp' );
PERCH_LOGINPATH: /cms
PERCH_PATH: /home/sites/juanfernandes.uk/public_html/cms
PERCH_CORE: /home/sites/juanfernandes.uk/public_html/cms/core
PERCH_RESFILEPATH: /home/sites/juanfernandes.uk/public_html/cms/resources
Image manipulation: GD
PHP limits: Max upload 64M, Max POST 64M, Memory: 128M, Total max file upload: 64M
F1: 2edba60ed1f613d6dd804feb202456a2
Resource folder writeable: Yes
HTTP_HOST: juanfernandes.uk
DOCUMENT_ROOT: /home/sites/juanfernandes.uk/public_html/
REQUEST_URI: /cms/core/settings/diagnostics/
SCRIPT_NAME: /cms/core/settings/diagnostics/index.php
Form
<perch:form id="subscribe" app="perch_mailchimp" double-optin="true" class="form form--subscribe">
<perch:success>
<p>Thank you!</p>
</perch:success>
<div class="content">
<p><b>Stay up-to-date with my blog posts and receive occasional emails from me.</b></p>
<div class="row">
<div class="six cols">
<perch:label for="firstname">First name</perch:label>
<perch:input id="firstname" required="true" type="text" mailer="FNAME" />
<perch:error type="required" for="firstname">Required</perch:error>
</div>
<div class="six cols">
<perch:label for="email">Email address</perch:label>
<perch:input id="email" required="true" type="email" mailer="email" />
<perch:error type="required" for="email">Required</perch:error>
</div>
<div class="four cols">
<button type="submit" value="Subscribe" id="btnsubmit" class="button--cta">Subscribe</button>
<perch:input type="hidden" value="1" id="confirm" mailer="confirm_subscribe" />
<perch:input type="hidden" id="list" value="your list ID goes here" mailer="list" />
</div>
</div>
<small><em>No spam ever, unsubscribe anytime.</em></small>
</div><!-- /.content -->
</perch:form>
You can set the
action
attribute on the form to match your URL format - that'll just get passed through.Hi Drew
Many thanks for your reply.
I'm totally lost here. I've tried various values for action, it has stopped the URL changing, but the form is not submitting, im not seeing the success message.
Juan
Make sure the value you set isn't incurring a redirect.
How do I set it so that its the current url?
Is my setup/how im using the mailchimp addon, different to how it was intended to be used?
So I have tested this with the form that you get out of the box with the addon, but tested it on a page on its own, not in a blog post - this works, so at least confirms the mail chimp integration is working.
And the URL does not change here, the form is at /signup/
Drew, how do I just output the post url?
I thought this would do it: action="<perch:blog id="postSlug" /> but i still get /blog/post.php?s=2016-12-09-post-name/
That depends on the context it's called in. I imagine you're not outputting anything and so Perch is taking over again.
View source and get the value of the
action
attribute.If i put in <perch:blog id="postSlug" /> in action="" I get: action="/blog/post.php?s=2016-12-09-post-title" but I need it to be action="/blog/2016-12-09-post-title"
So what you say about nothing being output and perch taking over is correct. So any ideas what I am doing wrong (million $ question!)
Thanks Juan
How are you displaying the form?
I'm displaying the form after the blog post and before the comment form
(https://imgur.com/a/ZSxGk)
In post.php
Try:
and
On the blog post, nothing is showing up after the actual post itself:
https://juanfernandes.uk/blog/2016-12-09-adding-svg-icons-to-a-sprite-with-perch-cms
So the subscribe form should be after the social share icons.
The post.php template:
Sorry, typo.
PerchUtil::set_var
should bePerchSystem::set_var
of course.Ah, sorry didn't notice that.
So this fixes the issue with the URL redirecting, thank you. So the issue here was that mailchimp didn't know about 'postURL' - correct?
But the when you fill in the form and submit it, the page refreshes, but nothing happens - no thank you message, and no new subscriber.
If you turn on debug, what does it output after the submit?
Am I supposed to be seeing any kind of output from enabling debug on the front end? - No output is shown
Ok i figured out what I was doing wrong
I was using this:
instead of:
Thank you very much for your support Drew.