Copied to clipboard

Flag this post as spam?

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


  • Marc-André 63 posts 279 karma points
    Jul 26, 2019 @ 15:31
    Marc-André
    0

    API : How can I get content from other culture?

    Hello community ;)

    I'm triyng to get pages with the API using Umbraco.Content(xxxx).Children, but it always return the content in his default culture.

    How can I specify the culture to get?

    Here's my code:

      public JsonResult<List<Retailer>> GetAll()
            {
              var retailers = new List<Retailer>();
              //This shit dosen't work
              var lang = HttpContext.Current.Request­.QueryString["lang"];
              var cultureInfo = CultureInfo.GetCultureInfo(lang);
              Thread.CurrentThread.CurrentCulture = cultureInfo;
              Thread.CurrentThread.CurrentUICulture = cultureInfo;
              //
              foreach (dynamic child in Umbraco.Content(1159).Children)
              {
                 retailers.Add(new Retailer() { Name = child.Name, Url = child.Url, City = child.Ville, Latitude = child.Latitude, Longitude = child.Longitude, Region = child.Region });
              }
    
              return Json(retailers, _settings);
            }
    
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies