@* ---------------- Newsletter Studio Subscribe ---------------- Use this simple macro to add a subscribe-box to your page. Please feel free to use this as a template, change it however you like. If you are planning to use this in production its a 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(txtEmail, txtName)) { // Trying to get the subscriptionId from Macro-parameter. Int32 subscriptionId = (Parameter.SubscriptionId != null) ? Convert.ToInt32(Parameter.SubscriptionId) : 0;
// Adding subsbriber //var success = (subscriptionId != 0) ? NewsletterStudio.Api.Subscribe(txtEmail, subscriptionId) : NewsletterStudio.Api.Subscribe(txtEmail); var success = (subscriptionId != 0) ? NewsletterStudio.Api.Subscribe(txtEmail, Common.UppercaseFirst (txtEmail.Substring(0, txtEmail.IndexOf("@")).Replace(".", " ")), subscriptionId) : NewsletterStudio.Api.Subscribe(txtEmail); showThankYou = true; } else { Error = "* Det er ikke en korrekt e-mail"; } } }
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
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:
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 != 0) ? NewsletterStudio.Api.Subscribe(txtEmail,
Common.UppercaseFirst(txtEmail.Substring(0, txtEmail.IndexOf("@")).Replace
(".", " ")), subscriptionId) : NewsletterStudio.Api.Subscribe(txtEmail);
Tanks
René
Hi!
This is due to a small bug in the system, please look at this post:
http://our.umbraco.org/projects/backoffice-extensions/newsletter-studio/comments/31574-Error-loading-MacroEngine-script-(file-NewsletterSubscribecshtml)
Hi
Here is hov i added name to the newsletter:
Add the Name field to form:
Add API SubScribe instead off IsValidEmail + "txtNamne"(Documentation page 15)
Add txtName
String txtName = Request.Form["txtName"].ToString();
Here is the complete code:
@*
---------------- Newsletter Studio Subscribe ----------------
Use this simple macro to add a subscribe-box to your page. Please feel free to use this as a template, change it however you like.
If you are planning to use this in production its a 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(txtEmail, txtName))
{
// Trying to get the subscriptionId from Macro-parameter.
Int32 subscriptionId = (Parameter.SubscriptionId != null) ? Convert.ToInt32(Parameter.SubscriptionId) : 0;
// Adding subsbriber
//var success = (subscriptionId != 0) ? NewsletterStudio.Api.Subscribe(txtEmail, subscriptionId) : NewsletterStudio.Api.Subscribe(txtEmail);
var success = (subscriptionId != 0)
? NewsletterStudio.Api.Subscribe(txtEmail, Common.UppercaseFirst (txtEmail.Substring(0, txtEmail.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>
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
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/
is working on a reply...