red sun Posted May 19, 2013 Share Posted May 19, 2013 The newsletter subscription box works but does not show a confirmation message. I'm sure on older versions of CC that you used to see a "subscription successful" message. There's a language setting for the success message: "newsletter.email_subscribed". I tried the CC site demo and it doesn't appear to be working on there either. Any help much appreciated... Quote Link to comment Share on other sites More sharing options...
bsmither Posted May 19, 2013 Share Posted May 19, 2013 In the file /classes/gui.class.php, near line 805, find the class method called _displayMailingList(). Make the following section of that function look like this and see what you get: if (isset($_POST['subscribe'])) { $newsletter = Newsletter::getInstance(); if ($newsletter->subscribe($_POST['subscribe'])) { $GLOBALS['gui']->setNotify($GLOBALS['language']->newsletter['notify_subscribed']); httpredir(currentPage(null, array('subscribed' => 'true'))); } else { $GLOBALS['gui']->setError($GLOBALS['language']->newsletter['email_invalid']); httpredir(currentPage(null, array('_a' => 'newsletter', 'subscribed' => 'false'))); } } Quote Link to comment Share on other sites More sharing options...
red sun Posted May 19, 2013 Author Share Posted May 19, 2013 Fantastic, thank you so much for your help. The function writes the following to the page: <div id="gui_message"> <div class="gui_message-notice">Your email address has been added to our mailing list.</div> </div> The message is appearing above the main page content as it does in the newsletter template page. Is there any way for it to appear in the newsletter box? Quote Link to comment Share on other sites More sharing options...
bsmither Posted May 19, 2013 Share Posted May 19, 2013 These statements:httpredir(currentPage(null, array('subscribed' => 'true')));httpredir(currentPage(null, array('_a' => 'newsletter', 'subscribed' => 'false')));are the initial step in implementing (as yet incomplete) a "double-opt-in" scenario. There is yet no code (that I can find) that processes the GET key/value of 'subscribed'/'true|false'. The email address that was inserted into the CC_newsletter_subscriber database table has a 'validation' value which will be used to have the subscriber validate from the email notice received. To do what you want, try: if (isset($_POST['subscribe'])) { $newsletter = Newsletter::getInstance(); if ($newsletter->subscribe($_POST['subscribe'])) { $GLOBALS['smarty']->assign('RSLT_SUBSCRIBED', true))); } else { $GLOBALS['smarty']->assign('RSLT_SUBSCRIBED', false))); } } Oops! Two too many closing parens on each statement. true); false); Then, in the skin template box.newsletter.php, find this sequence: {else} <form action="{$VAL_SELF}" method="post">make it look like: {elseif isset($RSLT_SUBSCRIBED)} {if $RSLT_SUBSCRIBED}{$LANG.newsletter.notify_subscribed}{else}{$LANG.newsletter.email.invalid}{/if} {else} <form action="{$VAL_SELF}" method="post">See what that does. (Be sure to clear the cache in CubeCart.) Quote Link to comment Share on other sites More sharing options...
red sun Posted May 19, 2013 Author Share Posted May 19, 2013 I cleared the cache and tried the solution above without any success. It removes the form, but doesn't show the success message. I've used the solution you posted in this topic http://forums.cubecart.com/topic/47361-resolved-using-php-in-templates as it addresses my issue perfectly and means that we don't have to alter any core files, which is always the best approach. This one Smarty statement should do the same as the {php} attempt: {if !empty($smarty.get.subscribed)}<p class="confirmation">Thank you for subscribing</p>{/if} See: http://www.smarty.ne....smarty.request Knackering the admin area... maybe. But there is a separate controller file for the admin. Many, many thanks for your assistance. Very much appreciated... Quote Link to comment Share on other sites More sharing options...
bsmither Posted May 19, 2013 Share Posted May 19, 2013 Well, I really messed it up here: $GLOBALS['smarty']->assign('RSLT_SUBSCRIBED', true))); } else { $GLOBALS['smarty']->assign('RSLT_SUBSCRIBED', false))); Two too many closing parentheses: $GLOBALS['smarty']->assign('RSLT_SUBSCRIBED', true); } else { $GLOBALS['smarty']->assign('RSLT_SUBSCRIBED', false); Quote Link to comment Share on other sites More sharing options...
red sun Posted May 19, 2013 Author Share Posted May 19, 2013 Hi there - I'd noticed that as DreamWeaver was highlighting it as a syntax error when I pasted the code into the page. Even after correcting it I got a blank box with no confirmation message. Quote Link to comment Share on other sites More sharing options...
bsmither Posted May 19, 2013 Share Posted May 19, 2013 If you still want to assist on figuring this out to its finale, in the file box.newsletter.php, add {debug} at the very end. Then enter a new email address in the field. When you click the submit button, a pop-up will show Smarty's diagnostics. Find the variable $RSLT_SUBSCRIBED (they are in alphabetical order). If it is not there, then the PHP assign statements didn't get executed: an email address that already exists or something doesn't really look like an email address was entered. If the variable is in the diagnostics, then there is a problem with the template file. Quote Link to comment Share on other sites More sharing options...
red sun Posted May 19, 2013 Author Share Posted May 19, 2013 My apologies, I must have been using an email address that I had used in a previous test, which was the reason the box was empty. All working perfectly now. Many thanks again for your assistance. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.