Copied to clipboard

Flag this post as spam?

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


  • Damiaan 442 posts 1302 karma points MVP 6x c-trib
    Jul 15, 2013 @ 17:07
    Damiaan
    0

    Language = null on contentService.GetById()

    Hi, 

    I am using the new v6 contentService on a umbraco 6.1.2

    When I do 

    var nodeLanguage = contentService.GetById(1083).Language;

    I always get back a null value.  I am pretty sure the "culture" is set on this node.  

    What is going wrong?

  • antao 81 posts 371 karma points
    Jul 16, 2013 @ 10:58
    antao
    0

    Hey Damiaan, did you set the culture and the hostname correctly? 

     

  • Damiaan 442 posts 1302 karma points MVP 6x c-trib
    Jul 16, 2013 @ 14:15
    Damiaan
    0

    Yes culture was set correctly.  In v6 you are not obligated to set a domain name when setting the Culture.  So no domain name was set.

  • Yiannis Vavouranakis 38 posts 78 karma points
    Jul 19, 2013 @ 11:43
    Yiannis Vavouranakis
    0

    I'm having the exact same problem. I can't find a way to retrieve a node's language/culture when no domain has been set. I tried the usual

    umbraco.library.GetCurrentDomains(pageId)

    but without setting a domain, the above gives me an array with no items.

    Then I tried 

     contentService.GetById(pageId).Language

    as the OP did, and got null. So how can we retrieve that piece of information?

    For the time being, I've  created a hacky workaround, I added a dummy hostname to each language root node, so that the GetCurrentDomains method returns a non-empty array. But this is definitely hacky. Ideally, one should be able to retrieve the "Language" setting in the "Culture" pane in the "Culture and hostnames" popup somehow.

  • Yiannis Vavouranakis 38 posts 78 karma points
    Jul 20, 2013 @ 01:12
    Yiannis Vavouranakis
    0

    Quick update:

    The workaround I posted earlier actually breaks NiceUrl. It seems that NiceUrl picks up the domain entered and prepends it - I can't seem to find a way to remove the domain prefix. Keeping it makes debugging a project next to impossible, since all links generated by NiceUrl are not "localhost".

  • Yiannis Vavouranakis 38 posts 78 karma points
    Oct 14, 2013 @ 12:49
    Yiannis Vavouranakis
    0

    Any solution to this? The issue is still persisting in 6.1.5 and I can't seem to find a valid workaround. The real question is, how do we retrieve a specific node's Culture, as set from within the umbraco interface, when no domain has been set?

  • Marco Teodoro 74 posts 149 karma points c-trib
    Nov 26, 2013 @ 17:13
    Marco Teodoro
    0

    i also have the same issue. Anyone find a nice workaround? is this a know issue on umbraco?

  • Yiannis Vavouranakis 38 posts 78 karma points
    Nov 26, 2013 @ 20:48
    Yiannis Vavouranakis
    0

    Well, it seems that it's done in 6.1.6. The Entity property of the event argument in the Created handler seems to have a numeric Id.

     

    Sorry, wrongfully posted in this thread for a reply to another thread. 

     

    No, the issue is still persisting in 6.1.6.

     

  • Tim 1193 posts 2675 karma points MVP 4x c-trib
    Nov 28, 2013 @ 11:52
    Tim
    0

    Have you logged this as an issue on http://issues.umbraco.org? If you log it there, there's a better chance of it getting seen by one of the core team than on here! I think Stephan (@zpqrtbnk on Twitter) is possibly the best person to answer this one.......

  • Yiannis Vavouranakis 38 posts 78 karma points
    Nov 28, 2013 @ 14:39
    Yiannis Vavouranakis
    0

    Just submitted this as http://issues.umbraco.org/issue/U4-3753 Thanks for the heads up.

  • Daniel Bardi 927 posts 2562 karma points
    Feb 25, 2015 @ 05:21
    Daniel Bardi
    0

    Still not fixed in version 7.2.1

  • Daniel Bardi 927 posts 2562 karma points
    Feb 25, 2015 @ 09:46
    Daniel Bardi
    0

    I commented on the issue.  Hoping it will get some love soon.  If not, I'm considering tackling it myself and submitting a pull request.

  • Warren Edwards 3 posts 23 karma points
    Apr 28, 2015 @ 14:13
    Warren Edwards
    0

    I am not using domains and implemented this workaround:

    Looking at the database struction (SQL CE in my instance), to find the language of the root node, I noticied I could start in the UmbracoDomains table to identify the ID of a root node. This record also has a domainDefaultLanguage which point to a language in the umbracoLanguage table.

    Thus, if you have a list of root node Ids, you can create a method that looks up the language for each root node.

    If a root ID was 1054, you could write the T-SQL like:

    select ul.languageISOCode from umbracoDomains ud

    join umbracoLanguage ul on ud.domainDefaultLanguage = ul.id

    where ud.DomainRootStructureID = 1054

    In my project, I've created a basic method that uses SqlCeConnection and pipes in the T-SQL command:

            public static string GetCultureAliasForRootNode(int rootNodeId) {

            {

                var connectionString = ConfigurationManager.ConnectionStrings["myUmbracoDSN"].ConnectionString;

                string cultureAlias;

                using (var connection = new SqlCeConnection(connectionString))

                {

                    connection.Open();

                    var command = connection.CreateCommand();

                    command.CommandText = "select ul.languageISOCode from umbracoDomains ud join umbracoLanguage ul on ud.domainDefaultLanguage = ul.id where ud.DomainRootStructureID = @rootNodeId";

                    command.Parameters.AddWithValue("@rootNodeId", rootNodeId);

                    cultureAlias = command.ExecuteScalar().ToString();

                }

                return cultureAlias;

            }

  • Warren Edwards 3 posts 23 karma points
    Apr 28, 2015 @ 14:19
    Warren Edwards
    0

    Using 'Microsoft.SqlServer.Compact 4.0.8876.1' nuget package to access the SQLCE database.

  • Yiannis Vavouranakis 38 posts 78 karma points
    Apr 28, 2015 @ 14:24
    Yiannis Vavouranakis
    0

    Thanks Warren.

     

    That would be a way to do it, however I prefer the Umbraco way (i.e. go through the API wherever possible).

    In any case, this issue has been addressed in 7.2.3 onwards.

     

    Cheers,
    Yiannis 

  • Warren Edwards 3 posts 23 karma points
    May 06, 2015 @ 16:27
    Warren Edwards
    0

    I'd also prefer to use the Umbraco API, but I'm using v7.2.4 and it doesn't work as expected.

  • Scott Donovan 2 posts 72 karma points
    Feb 02, 2016 @ 16:41
    Scott Donovan
    0

    This is still an outstanding issue - when will this be fixed?

  • 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