Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • René 327 posts 852 karma points
    May 14, 2012 @ 15:41
    René
    0

    Add name to subscription - News letter studio

    Hi 

    Umbraco version 4.7.2

     

    I need to add a field for the name of the subscriber, is there an easy way.

    I have added the field to the form:

    <div class="newsletter-form">
            <form method="post" action="@Request.Url">
                <input type="hidden" name="action" value="subscribe" />
                <label for="txtName">Dit navn</label>
                <input type="text" name="txtName" id="txtName" class="txt" size="12" />
                <label for="txtEmail">E-mail<span style="color:Red">@Error</span></label>
                <input type="text" name="txtEmail" id="txtEmail" class="txt" size="12" />
                <input type="submit" id="btnSubmit" value="Tilmeld" class="btn" />
            </form>
        </div>

    Now i need to add the name to the "AddidngSubscriber"

    I have tryed to add name instead of txtEmail but i cant get to work.

    A small help pointing in the right direction would help. I cant see it in the documentation.

    
    // Adding subsbriber
     var success (subscriptionId != 0NewsletterStudio.Api.Subscribe(txtEmail,
     
    Common.UppercaseFirst(txtEmail.Substring(0txtEmail.IndexOf("@")).Replace
    ("."" "))subscriptionIdNewsletterStudio.Api.Subscribe(txtEmail);
                 

    Tanks 

    René

  • Markus Johansson 1936 posts 5864 karma points MVP 2x c-trib
    May 14, 2012 @ 15:43
  • René 327 posts 852 karma points
    May 15, 2012 @ 10:47
    René
    0

    Hi 

    Here is hov i added name to the newsletter:

    Add the Name field to form:

    <div class="newsletter-form">
            <form method="post" action="@Request.Url">
                <input type="hidden" name="action" value="subscribe" />
                <label for="txtName">Dit navn</label>
                <input type="text" name="txtName" id="txtName" class="txt" size="12" />
                <label for="txtEmail">E-mail<span style="color:Red">@Error</span></label>
                <input type="text" name="txtEmail" id="txtEmail" class="txt" size="12" />
                <input type="submit" id="btnSubmit" value="Tilmeld" class="btn" />
            </form>
        </div>

    Add API SubScribe instead off IsValidEmail + "txtNamne"(Documentation page 15)

    if (NewsletterStudio.Api.Subscribe(txtEmailtxtName))

    Add txtName

     String txtName Request.Form["txtName"].ToString(); 


    Here is the complete code:

    @*
    ---------------Newsletter Studio Subscribe ----------------
    Use this simple macro to add subscribe-box to your page. Please feel free to use this as templatechange it however you like.
    If you are planning to use this in production its good idea to move the CSS into you master-stylesheet.

    *@

    @using NewsletterStudio

    @inherits umbraco.MacroEngines.DynamicNodeContext

    @{
        
        bool showThankYou false;
        string Error "";
        
        if (Request.Form["action"!= null &Request.Form["action"].ToString(== "subscribe" &Request.Form["txtEmail"].ToString(!= ""
        {
            String txtEmail Request.Form["txtEmail"].ToString();
            String txtName Request.Form["txtName"].ToString();
         
            if (NewsletterStudio.Api.Subscribe(txtEmailtxtName))
            {
                // Trying to get the subscriptionId from Macro-parameter.
                Int32 subscriptionId (Parameter.SubscriptionId != nullConvert.ToInt32(Parameter.SubscriptionId0;

                // Adding subsbriber
                //var success (subscriptionId != 0NewsletterStudio.Api.Subscribe(txtEmailsubscriptionIdNewsletterStudio.Api.Subscribe(txtEmail);
                 
                var success (subscriptionId != 0
                     NewsletterStudio.Api.Subscribe(txtEmailCommon.UppercaseFirst (txtEmail.Substring(0txtEmail.IndexOf("@")).Replace("."" "))subscriptionId
                      NewsletterStudio.Api.Subscribe(txtEmail);
                
             showThankYou true;
            }
            else
            
                Error "* Det er ikke en korrekt e-mail";
            }
        }
    }

    <div class="newsletter">

    @if (!showThankYou)
    {       
         <div class="newsletter-form">
            <form method="post" action="@Request.Url">
                <input type="hidden" name="action" value="subscribe" />
                <label for="txtName">Dit navn</label>
                <input type="text" name="txtName" id="txtName" class="txt" size="12" />
                <label for="txtEmail">E-mail<span style="color:Red">@Error</span></label>
                <input type="text" name="txtEmail" id="txtEmail" class="txt" size="12" />
                <input type="submit" id="btnSubmit" value="Tilmeld" class="btn" />
            </form>
        </div>
    }
    else

         <div id="newsletter-thankyou">
            <p>Tak for tilmelding</p>
        </div>
    }
    </div>
            
  • Markus Johansson 1936 posts 5864 karma points MVP 2x c-trib
    May 15, 2012 @ 10:58
    Markus Johansson
    0

    Hi!

    Thank you!

    Thing is that there is a bug in one of the methods on the API-class, this will be solved in the upcomming release which will include support for MySQL as well =D

    / m

  • Markus Johansson 1936 posts 5864 karma points MVP 2x c-trib
    May 18, 2012 @ 08:51
    Markus Johansson
    0

    Hi René!

    Just want to let you know that this bug is resolved in version 1.2.2, which also supports MySQL.

    http://our.umbraco.org/projects/backoffice-extensions/newsletter-studio/

Please Sign in or register to post replies

Write your reply to:

Draft