Copied to clipboard

Flag this post as spam?

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


  • Jason Espin 368 posts 1335 karma points
    Apr 30, 2015 @ 11:48
    Jason Espin
    0

    Cannot use getCulture() on an IPublishedContent object in API controller

    Hi all,

    I have a bit of a dilemma. I am using Umbraco 7.2.4 after being told that this version is required to be able to access the culture of a page.

    https://our.umbraco.org/forum/umbraco-7/using-umbraco-7/64353-Accessing-the-language-culture-of-a-page-from-the-Umbraco-content-service

    However, I am unable to access this property when working with an IPublishedContent object in an API controller. This is vital as I need to be able to select and work with the correct pages based upon their culture for my application to ensure that data is injected into the correct language nodes via the content service.

    Does anyone know how I can get this to work or get the culture?

    So far I am doing the following:

    IContentService cs = ApplicationContext.Current.Services.ContentService;
    
     IEnumerable<IContent> homepages = null;
     homepages = cs.GetRootContent().Where(x => x.ContentType.Alias == "home");
     foreach (IContent homepage in homepages)
     {
        IPublishedContent page = Umbraco.TypedContent(homepage.Id);
        string culture = page.GetCulture().ToString();
     }
    

    However, the GetCulture() method is marked as invalid in Visual Studio.

  • Calle Bjernekull 28 posts 103 karma points
    Apr 30, 2015 @ 13:03
    Calle Bjernekull
    100

    First of all, the GetCulture()-methot is in the extension Umbraco.Web.PublishedContentExtensions. Did you include the Umbraco.Web-namespace?

    Secondly, do you use diffrent hosts to for each culture?

Please Sign in or register to post replies

Write your reply to:

Draft