Coded something up in Couch in an interesting way? Have a snippet or shortcode to share? Post it here for the community to benefit.
35 posts Page 2 of 4
I've tested this on a local setup and it worked just fine. It may ultimately be a factor for you, but let's first try to rule it out.

Have you made sure to enter your api key and list id in the admin panel? After the following:
Code: Select all
echo "<div class=\"error\">An unknown error was encountered. Please try again later or contact us.</div>";
Please add:
Code: Select all

Could you post what message you receive now?
Hi again,

Have you made sure to enter your api key and list id in the admin panel?

I really don't know what you are talking about... I did nothing else than download Mailchimp.php, Newsletter.php, and include <cms:form action...></cms:form> in the blog. I only use html/css as I can, looking in code source and following tutos on the web !

So, I added this
Code: Select all

and the result is the same page saying an unknown error was encountered.

I am too ignorant :oops:
That's perfectly alright @coeur2louve. ;)

1. Create an account with MailChimp:
2. Create and copy your API key:
3. Create a list and copy its ID:
4. Enter the API key and list ID you saved above in the admin panel editable regions for newsletter.php.
5. Try again?
Dear Cheesyproof,

Your explainations are so clear !
Now, it works :P

Happy new year

I'm glad you got this to work. As always, do let us know if you have any questions.

Happy new year :)
hi cheesypoof - will this enable subscribers to unsubscribe?
Yes @potato, MailChimp adds an unsubscribe link to every newsletter email by default:
It works well... cool!

Just to let you know that mail chimp has changed the class file, now it should read

<?php require_once( 'Drewm/MailChimp.php' ); ?> or
<?php require_once( 'MailChimp.php' ); ?>

instead of
<?php require_once( 'cms/cms.php' ); ?>
<?php require_once( 'MailChimp.class.php' ); ?>
Thanks Paolo - example code updated.
I have finally used Cheesypoof's code for a MailChimp signup form ( - after battling with the MailChimp embed form previously with trying to override styles and getting inline validation to work - it kept going off to the MailChimp hosted error page!). Thank you cheesypoof - superbly well documented ...

I used the stripped down code ...
Code: Select all
<cms:form action="<cms:link 'newsletter.php'/>" method='post' name='subscribe'>
    <cms:input name='email' placeholder='Email Address' required='1' type='text' validator='email'/>
    <input type="submit" value="Subscribe to Newsletter">

in another template mailinglist.php - but found that when there is a validation error (say, invalid email address) the user is taken from current page off to newsletter.php for the error to display. I'm guessing that this is how it works - or have I implemented the solution wrongly?

I changed it to the following in mailinglist.php:
Code: Select all
<?php require_once( 'admin/cms.php' ); ?>
<?php require_once( 'MailChimp.php' ); ?>
<cms:template title='Mailing List'>
<div id="form2">
<cms:form method='post' name='subscribe'>
    <cms:if k_success>
       <cms:check_spam email=frm_email />
            $MailChimp = new \Drewm\MailChimp(' ... MAILCHIMP API KEY HARDCODED HERE ...');

            $result = $MailChimp->call('lists/subscribe', array(
                'id'    => ' ... MAILCHIMP LIST ID HARDCODED HERE ...',
                'email' => array('email' => '<cms:show frm_email/>')

            if (isset($result['email'])) {
                echo "<div class=\"success\">We have sent you an email - please click on the link to confirm your subscription!</div>";
            } else if (isset($result['status']) &&
                       $result['status'] === 'error' &&
                       $result['name'] !== 'List_AlreadySubscribed') {
                echo "<div class=\"error\"><strong>" . $result['name'] . " (" . $result['code'] . "):</strong> " . $result['error'] . "</div>";
            } else {
                echo "<div class=\"error\">An unknown error was encountered. Please try again later or contact us.</div>";
           <legend>Sign up to our newsletter</legend>                                                       
            <div class="form-group<cms:if k_error_email> has-feedback</cms:if>">
               <label class="sr-only control-label" for="email">Email</label>
               <cms:input type="text"
                          placeholder='your email address'
                          validator_msg='required=Please enter your email address! | email=Sorry - not a valid email address'
               <cms:if k_error_email><span class="glyphicon glyphicon-remove form-control-feedback position-icon"></span><span class="k-error"><cms:show k_error_email /></span></cms:if>
        <button type="submit" class="btn btn-default">Sign up!</button>

As I am doing this somewhat blindly - copying and amending from an expert - I just wondered if there was anything I am missing?!
35 posts Page 2 of 4

Who is online

In total there are 3 users online :: 0 registered, 0 hidden and 3 guests
(based on users active over the past 5 minutes)

Users browsing this forum: No registered users and 3 guests