I guess you could set up the lists, one for each culture, then get the page culture and use the API to subscribe to the relevant list. For less use of magic strings, you could have the culture-to-list relation in a config file and read it from there.
As Yiannis is saying you could of curse code this your self or just add different macros to the different cultures. It really depends on your setup if you have the macro inside a template or if its inserted in the rich text editor (if the later its just a matter of setting the correct mailig list for the macro).
I have 2 subscription ID's 1 and 2. 1 being English and 2 being Welsh.
When a user first hits the site, they will see the english version of the site. The culture code isn't present in the URL initially. We only see /en or /cy when the user switches between cultures.
Please can anyone help me with the code I need to add a subscription to the correct list based on the culture?
I'm assuming I need to amend the following code:
if (NewsletterStudio.Api.IsValidEmail(txtEmail)) { // Trying to get the subscriptionId from Macro-parameter. Int32 subscriptionId = (Parameter.SubscriptionId != null) ? Convert.ToInt32(Parameter.SubscriptionId) : 0;
add to list based on culture
Hi,
I would like to purchase the package for a client. However, the site is bilingual and uses 2 cultures. en and cy
On subscribe, the user would need to be added to a list in the newsletter studio section based on the culture they are viewing the site in.
The default culture is /en. When a user first loads the site, no culture is selected so it defaults to en even though the url doesn't show /en
Is this possible?
Thanks
Hello.
I guess you could set up the lists, one for each culture, then get the page culture and use the API to subscribe to the relevant list. For less use of magic strings, you could have the culture-to-list relation in a config file and read it from there.
HTH
Yiangos
Hi!
As Yiannis is saying you could of curse code this your self or just add different macros to the different cultures. It really depends on your setup if you have the macro inside a template or if its inserted in the rich text editor (if the later its just a matter of setting the correct mailig list for the macro).
/ m
Thanks for the replies.
I'm using the same templates for both cultures.
I have 2 subscription ID's 1 and 2. 1 being English and 2 being Welsh.
When a user first hits the site, they will see the english version of the site. The culture code isn't present in the URL initially. We only see /en or /cy when the user switches between cultures.
Please can anyone help me with the code I need to add a subscription to the correct list based on the culture?
I'm assuming I need to amend the following code:
if (NewsletterStudio.Api.IsValidEmail(txtEmail))
{
// 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);
showThankYou = true;
}
else
{
Error = @Dictionary["Email Required"];
}
Many thanks
Roger
Hi!
Yes, you would probably need to get the current culture and based on that insert into the right mailing list (or subscription id).
More about the current culture: http://our.umbraco.org/forum/developers/api-questions/15942-CurrentUICulture-and-CurrentCulture?p=1 ;
You could also add the mailing list id as a dictionary item and then do something like:
// Try getting the mailinglist id from the dictionary
Int32 mailingListId = Convert.ToInt32(umbraco.library.GetDictionaryItem("mailingListId"));
// Adding subsbriber to the right mailing list.
NewsletterStudio.Api.Subscribe(txtEmail, mailingListId)
// m
Thanks, the dictionary item method worked perfectly!
is working on a reply...