Copied to clipboard

Flag this post as spam?

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


  • Ívar Oddsson 9 posts 100 karma points
    Jan 23, 2017 @ 17:57
    Ívar Oddsson
    1

    Unable to retrieve data from Vorto with GetVortoValue.

    Hi there.

    I'm trying to use Vorto but after having installed it I'm running into some troubles. The HasVortoValue and GetVortoValue extensions do not work as expected.

    I'm trying to use HasVortoValue like this:

    var something = somethingElse.HasVortoValue("markerText");

    And even though somethingElse has a property with the propertyTypeAlias "markerText" and values {[en, English text from Vorto ]} and {[is, Icelandic text from Vorto]}, HasVortoValue still returns false and

    var markerText = somethingElse.GetVortoValue("markerText");

    returns null. In other words, it looks like the data is present but I am not able to retrieve it. Hope this makes sense, this is the first time I'm using Vorto :)

  • Micha Somers 134 posts 597 karma points
    Jan 23, 2017 @ 19:07
    Micha Somers
    0

    HasVortoValue and GetVortoValue are extensions for IPublishedContent.

    If you cast somethingElse to IPublishedContent and then call HasVortoValue/GetVortoValue on that PublishedContent, I think it will work.

  • Ívar Oddsson 9 posts 100 karma points
    Jan 24, 2017 @ 09:50
    Ívar Oddsson
    0

    Hi Micha, thanks for the reply.

    I'm actually looping through IPublishedContent nodes so somethingElse is of type IPublishedContent. Nevertheless I did try to assign somethingElse to a variable of type IPublishedContent but I'm getting the same results.

    Others, that have experienced similar problems, have suggested that Vorto behaves this way if the values language I'm trying to retrieve does not correspond to the current culture of my project (f.x. if my current culture is en-US and the Vorto value I'm trying to retrieve does not have a value for that language). See: https://our.umbraco.org/projects/backoffice-extensions/vorto/bugs-feedback-suggestions/52887-GetVortoValue(propertyName)-returning-null#comment-183955

    So I tried to manually set the current culture of the thread to icelandic like so:

    Thread.CurrentThread.CurrentCulture = new CultureInfo("is-IS");
    Thread.CurrentThread.CurrentUICulture = new CultureInfo("is-IS");
    

    I have also tried to use the cultureName variable of the GetVortoValue extension like so:

    GetVortoValue("markerText", "is-IS");
    

    That does not seem to work either :/

  • Micha Somers 134 posts 597 karma points
    Jan 24, 2017 @ 11:06
    Micha Somers
    0

    It is remarkable that calling

    GetVortoValue("markerText", "is-IS");

    did not work ...

    What kind of culture info result do you get when calling:

    somethingElse.GetCulture() 
    

    Further, I wonder if your property is defined on several levels, having it filled in on only one of these levels?

    If so, can you try to set the recursive parameter of GetVortoValue to true?

  • Ívar Oddsson 9 posts 100 karma points
    Jan 24, 2017 @ 13:56
    Ívar Oddsson
    0

    I'm getting the Icelandic culture info when I call

    somethingElse.GetCulture()
    

    I would expect "Icelandic text from Vorto" to be returned.

  • Micha Somers 134 posts 597 karma points
    Jan 24, 2017 @ 18:24
    Micha Somers
    0

    Actually, it's ok that GetCulture returns the Icelandic culture info. At least, the culture for that node is known and is as expected.

    So far, it looks like the published somethingElse node for which GetVortoValue is called really does not have any translated text defined for the property with alias markerText.

    Next step would be to check if the latest changes, especially with regards to the translations, have been published.

    Another thing to try, is to inspect the somethingElse node (for example the .Path and .Level property) to see if you are really looking at the node you expect to look at.

    Maybe you can share some code that shows how you obtain somethingElse?

  • Rasmus Eeg 91 posts 457 karma points c-trib
    Jan 26, 2017 @ 06:25
    Rasmus Eeg
    0

    Hi there,

    Could you try an post the result of:

    @Newtonsoft.Json.JsonConvert.SerializaObject(publishedContent.GetPropertyValue("markerText"))

  • Ívar Oddsson 9 posts 100 karma points
    Jan 27, 2017 @ 09:20
    Ívar Oddsson
    0

    Hi Rasmus.

    JsonConvert.SerializeObject(publishedContent.GetPropertyValue("markerText"));
    

    returns

    "{\"values\":{\"en\":\"This is en text\",\"is\":\"Þetta er ísl texti\"},\"dtdGuid\":\"703ea27b-058d-4f03-83c2-88059e7e4cf8\"}"

    Just so everything is completely clear, this is what I'm doing exactly:

    1. I created a method in a UmbracoAPIController that calls a method in another class. That method constructs and returns a GEOJson object.
    2. I'm using XMLHttpRequest in my JS to call the UmbracoAPIController method and retrieve the GEOJson object.

    I am not using Vorto in a Razor view, I'm using it in the method that constructs the GEOJson object. I'm not sure if that was clear :)

  • Rasmus Eeg 91 posts 457 karma points c-trib
    Jan 27, 2017 @ 11:15
    Rasmus Eeg
    100

    Hi Ivar,

    It seems like you are trying to get the Icelandic text using "is-IS" and not "is" as the result here suggest:

      "values": {
        "en": "This is en text",
        "is": "Þetta er ísl texti" // saved as is and not is-IS
      }
    

    Could you try the following:

    GetVortoValue("markerText", "is")
    
  • Ívar Oddsson 9 posts 100 karma points
    Jan 27, 2017 @ 11:51
    Ívar Oddsson
    0

    When you've been staring at the same code for so long you tend to miss the little things. I did not realize Iceland had two different culture codes (it doesn't make a lot of sense either).

    Thanks for the help :D

Please Sign in or register to post replies

Write your reply to:

Draft