Copied to clipboard

Flag this post as spam?

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


  • Roger 195 posts 474 karma points
    Oct 07, 2013 @ 18:19
    Roger
    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

  • Yiannis Vavouranakis 36 posts 76 karma points
    Oct 07, 2013 @ 18:23
    Yiannis Vavouranakis
    0

    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

  • Markus Johansson 1915 posts 5762 karma points MVP c-trib
    Oct 07, 2013 @ 19:21
    Markus Johansson
    0

    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

  • Roger 195 posts 474 karma points
    Oct 08, 2013 @ 12:05
    Roger
    0

    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

  • Markus Johansson 1915 posts 5762 karma points MVP c-trib
    Oct 08, 2013 @ 12:19
    Markus Johansson
    100

    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

                    

  • Roger 195 posts 474 karma points
    Oct 08, 2013 @ 12:46
    Roger
    0

    Thanks, the dictionary item method worked perfectly!

Please Sign in or register to post replies

Write your reply to:

Draft