Kinetic Pulse
  • Home
  • Services
  • Portfolio
  • Blog
  • Terms
  • Contact

Creating holding page with working subscribe box for Magento site

November 29, 2011

I recently had to “hide” a fully working Magento site due to an upgrade.

However the client insisted on having a working “sign up to my newsletter” box on the holding page too, and wanted all the collected email addresses to be collected in Magento as normal, and not in Mailchimp or any other newsletter program.

So I rolled up my sleeves and tried to figure out how to do it. This is the quick and dirty way I ended up doing it.

First I created my holding page in a separate folder called holdingpage\index.php

(I based it on an existing page from the Magento site, by copying the source HTML and slicing out bits I didn’t need.)

Then I edited the .htaccess so  that this page was always redirected to. (there are several posts out there on how to do it but here’s my take on it)

Change the follwoing line:

DirectoryIndex index.php

to

DirectoryIndex holdingpage/index.php

and also change

RewriteRule .* index.php [L]

to

RewriteRule .* holdingpage/index.php [L]

(obviously if you want to undo these changes at a later date I suggest you just comment out the old line by preceding it with a ‘#’)

Now that seemed to do the trick that everything was going to my new holding page. First task done.

Next I had to figure out how to get that newsletter subscribe working. Now I’m not a huge fan of Magento as it seems to over complicate a lot of stuff (and is mightily slow etc etc) so cover your eyes people if you are a fan of code purity.

I used regular PHP and MySQl to get this done. Turns out the newsletter_subscribers table isn’t one of the ones that is used in all the Magento indexing, so I could just update it using a regular MySQL statement.

I added the following code to the top of my index.php

<?php
if($_POST["email"]!=""){
    global $con;
    $con = mysql_connect("DBHOSTNAME","DBUSERNAME","DBPASSWORD"); 
    if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }  
    mysql_select_db("DBNAME", $con);

    $strSQL="INSERT INTO `newsletter_subscriber` (`subscriber_id`, `store_id`, `change_status_at`, `customer_id`, `subscriber_email`, `subscriber_status`, `subscriber_confirm_code`) VALUES (NULL, '1', NULL, '0', '".$_POST["email"]."', '1', 'NULL');";

    mysql_query($strSQL);
}
?>

Note: I only have 1 store so have hardcoded those values

I added the following block just below the heading area of my holding page to generate a friendly message on sucessful subscription.

<? if($_GET["subscribe"]==1){?>
           <ul>
               <li>
                <ul><li><span> 
                    Thank you for subscribing to our newsletter. You'll hear from us soon...
                </span></li></ul>
            </li>
           </ul>
<? } ?>

And the subscribe form is just:

<div>
    <div>
        <strong><span>Join Our Mailing List</span></strong>
    </div>
    <form id="newsletter-validate-detail" method="post" action="/newsletter/subscriber/new/?subscribe=1">
        <div>
            <label for="newsletter"></label>
            
               <input type="text" value="enter your email address" title="Sign up for our newsletter" id="newsletter" name="email" onfocus="if(this.value=='enter your email address'){this.value=''}" onblur="if(this.value==''){this.value='enter your email address'}">
            
            <div>
                <button title="SUBMIT" type="submit"><span><span>SUBMIT</span></span></button>
            </div>
        </div>
    </form>
    <script type="text/javascript">
    //&lt;![CDATA[
        var newsletterSubscriberFormDetail = new VarienForm('newsletter-validate-detail');
    //]]&gt;
    </script>
</div>

Which the eagle-eyed of you will notice is just the default Magento HTML it generates for a subscribe box. Note: I have addedd subscribe=1 to the action parameter of the form too, which is used to display the message.

I admit its not pretty but it is quick and dirty and most importantly it works!

Share

Facebook Google+ Twitter Pinterest Email
  1. Dan Mac Leon says

    January 9, 2013 at 10:40 pm

    Nice job. What a pain Magento can be. This will help next time I need to do some maintenance.

    Also, I was wondering about sub pages

    magento/bargins or magento/about-us etc.

Back to Blog

Testimonials

Absolutely fantastically professional web developer – I would highly recommend!!! Thank you so much Kinetic Pulse!
Tania MarstonDoris Designs
It’s been fab working with you – we love the site and certainly going to recommend you!
James DaviesThirty Eight Degrees North
Thanks so much for all your work on this, really appreciated. It’s come on in leaps and bounds since you took over.
Pete KewRedwood Strip Curtains
Amazing and brilliant, Kinetic Pulse have lifted a dream to reality, Highly recommended and great if you are total novice, they know their stuff…Thanks again
Annie LindridgeSalt Yourself Out
Thank you for all of your hard work its looks fab and I am over the moon with it!
Amanda MercerAmanda Mercer Ceramics
Thank you guys so much for all that you’ve done helping us to create a really awesome website!! We get such great feedback – everyone loves it & we couldn’t be prouder! Look forward to working with you again soon!
Wild Thyme PlantsWild Thyme Plants
I like it.  I like it a lot !!!

 You have interpreted what I wanted to achieve perfectly considering what you have to play with i.e not redoing the whole thing in the process.

Fiona Simmons-MooreSouth Gloucestershire Parents & Carers

Copyright 2025 Kinetic Pulse