0

Can any one help correct what I think is a coding issue. I have taken the code for the Magento inbuilt newletter subscription block and used it to create a widget so I can place a further newsletter signup option at the top of my home page.

However, in the image below you can see that it is not displaying correctly and is showing some of the code on the front end.

Screenshot

This is the code I have used;

<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category    design
 * @package     base_default
 * @copyright   Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
 * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */
?>
<div id="subscribe-form" class="clearer">
    <form action="<?php echo $this->getFormActionUrl() ?>" method="post" id="newsletter-validate-detail">
        <div>
            <label for="newsletter"><?php echo $this->__('Sign up') ?></label>
            <div class="input-box">
                <input type="text" name="email" id="newsletter" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Sign up for our newsletter')) ?>" class="input-text required-entry validate-email" />
            </div>
            <button type="submit" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Subscribe')) ?>" class="button btn-inline"><span><span><?php echo $this->__('Subscribe') ?></span></span></button>
        </div>
    </form>
</div>
<script type="text/javascript">
//<![CDATA[
    var newsletterSubscriberFormDetail = new VarienForm('newsletter-validate-detail');
    new Varien.searchForm('newsletter-validate-detail', 'newsletter', '<?php echo Mage::helper('core')->jsQuoteEscape($this->helper('newsletter')->__('Enter your email address')) ?>');
//]]>
</script>

Can anyone advise how I rectify this please?

Thank you

  • What's the layout xml code that adds that new template to your page ? – Raphael at Digital Pianism Jun 7 '16 at 14:39
  • Hi. Where will I find that? – Jimnibob Jun 7 '16 at 15:30
  • Well I don't know, how did you add that block to the top of your page ? – Raphael at Digital Pianism Jun 7 '16 at 15:31
  • I created a new static block. Added the above code to its content and then created a widget to place that static block at the top of the page. – Jimnibob Jun 7 '16 at 15:33
0

Just found the solution in this post - https://stackoverflow.com/questions/3420285/newsletter-signup-on-cms-page-in-magento

As I have limited knowledge in this kind of stuff I was applying my own logic to approach what I wanted to achieve and ultimately tring to do it the hard way.

The simple solution was to create a static block and add the following to its content;

{{block type="core/template" template="newsletter/subscribe.phtml"}}

Then create a widget to place the static block where I want it

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.