Copied to clipboard

Flag this post as spam?

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


  • Peter Cort Larsen 421 posts 1038 karma points
    Jun 16, 2014 @ 21:55
    Peter Cort Larsen
    0

    get value by language

    Hi,

    Shouldnt i be able to do this, where is my language code eg. da-DK or en-US.
    I am using webforms and 7.1.4

    if (@Model.HasVortoValue("bodyText"))
    {
    @Model.GetVortoValue("bodyText",lang).Value
    }
  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Jun 18, 2014 @ 11:10
    Matt Brailsford
    0

    Hi Peter,

    What is @Model in your example? If it's an IPublishedContent then yes, you should be able to get a specific language by passing in the ISO code to the GetVortoValue method.

    Could you explain what exactly is going wrong in your example?

    Many thanks

    Mat

  • Peter Cort Larsen 421 posts 1038 karma points
    Jun 18, 2014 @ 12:07
    Peter Cort Larsen
    0

    Hi,

    Model is the current page like always.


    My set so far is pretty simple, should work.

     

  • Peter Cort Larsen 421 posts 1038 karma points
    Jun 18, 2014 @ 12:10
    Peter Cort Larsen
    0

    My hostnames are setup correctly,.

    Calling Model.GetPropertyValue("bodyTitle")
    returns:

     

    {"values":{"da-DK":"yutyrgdcvx z"},"dtdGuid":"c17be0c9-8dc2-43c7-bd06-6373db8f8e0b"}

     

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Jun 18, 2014 @ 12:12
    Matt Brailsford
    1

    Hi Peter,

    Ok, then you'll need to change it to be:

    @if(Model.Content.HasVortoValue("bodyText")){
      @Model.Content.GetVortoValue("bodyText")
    }
    

    The HasVortoValue and GetVortoValue extension methods only work on an IPublishedContent entity, which in a standard razor view is at @Model.Content.

    Hope this helps

    Matt

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Jun 18, 2014 @ 12:17
    Matt Brailsford
    0

    PS Also make sure you have the Vorto using statement at the top of you view (before the @inherits bit) @using Our.Umbraco.Vorto.Extensions;

    Many thanks

    Matt

  • Peter Cort Larsen 421 posts 1038 karma points
    Jun 18, 2014 @ 12:58
    Peter Cort Larsen
    0

    Hi,

    It dosnt make a difference, i already tried that earlier.

    I am trying this now. No value returned, No errors in console. Nothing in the log.

    @inherits umbraco.MacroEngines.DynamicNodeContext
    @using Our.Umbraco.Vorto.Extensions;
    @if(Model.Content.HasVortoValue("bodyText"))
    {
    @Model.Content.GetVortoValue("bodyText")
    }
  • Peter Cort Larsen 421 posts 1038 karma points
    Jun 18, 2014 @ 12:59
    Peter Cort Larsen
    0

    Upps, 

    and putting the Vorto using statement at the very top dosnt make a difference.

  • Peter Cort Larsen 421 posts 1038 karma points
    Jun 18, 2014 @ 13:03
    Peter Cort Larsen
    0

    Under installed packages i get version number 1.1
    But here when you download Vorto it says 1.2

    I added the vorto yester today.

    But can that be it??

     

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Jun 18, 2014 @ 13:04
    Matt Brailsford
    0

    Hmm, it might be worth checking what the website thinks is the current culture. Maybe try outputting the current culture via @(System.Globalization.CultureInfo.CurrentCulture.Name) and see if it matches "da-DK" given that that is the only culture you have a value for.

    Matt

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Jun 18, 2014 @ 13:05
    Matt Brailsford
    0

    Regarding 1.1 and 1.2 that might just be me forgetting to update the version number in the DLL, I'll double check that, but I don't think that will affect you here.

  • Peter Cort Larsen 421 posts 1038 karma points
    Jun 18, 2014 @ 13:14
    Peter Cort Larsen
    0

    Hi,

    I tried installing Vorto on different solution. Now the version number says 1.2, but to no avail. Still i dont see any data.

    Outputting @(System.Globalization.CultureInfo.CurrentCulture.Name) gives me the correct culture, as expected.

    Damn, this package is so sweet, just what i need.

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Jun 18, 2014 @ 13:21
    Matt Brailsford
    0

    Hi Peter,

    What do you get if you just output @Model.Content.GetVortoValue("bodyText", "da-DK")? (no if statement)

    Matt

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Jun 18, 2014 @ 13:23
    Matt Brailsford
    0

    Also, maybe try outputting @System.Threading.Thread.CurrentThread.CurrentUICulture.Name as this is actually what Vorto uses to detect the current culture (it should be the same as the last one though, but worth checking).

  • Peter Cort Larsen 421 posts 1038 karma points
    Jun 18, 2014 @ 13:30
    Peter Cort Larsen
    0

    Hi,

     

    Tried these, without any luck.

    @Model.Content.GetVortoValue("bodyText", "da-DK")

    @Model.Content.GetVortoValue("bodyText", "da-DK").Value

    I also tried all this on a different solution, same prob.

    Outputting  @System.Threading.Thread.CurrentThread.CurrentUICulture.Name also gives the correct culture.

     

  • Peter Cort Larsen 421 posts 1038 karma points
    Jun 18, 2014 @ 13:31
  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Jun 18, 2014 @ 14:47
    Matt Brailsford
    0

    Hmmm, very interesting. Out of interest, what Data Type are you wrapping with Vorto? (couldn't find that dtdGuid in the Umbraco source).

    The only thing I could think to do is either a) for you to download the source from github and debug through these extension methods to see what is going on https://github.com/mattbrailsford/Vorto/blob/master/Src/Our.Umbraco.Vorto/Extensions/IPublishedContentExtensions.cs or b) if you could zip up your install including DB and I could try and replicate your install.

    Let me know if either one of those are an option. I can't really see from the code here why it shouldn't be working for you.

    Many thanks

    Matt

  • Peter Cort Larsen 421 posts 1038 karma points
    Jun 18, 2014 @ 15:02
  • Peter Cort Larsen 421 posts 1038 karma points
    Jun 18, 2014 @ 15:03
    Peter Cort Larsen
    0

    And thanks for your help.

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Jun 18, 2014 @ 15:32
    Matt Brailsford
    0

    Hi Peter,

    I've got it up an running and I think I see what the problem is now. You seem to be using the old RazorMacroEngine rather than the newer MVC Partials macro engine which is what you'd need to use with Vorto (or just plain old Partials would work fine too).

    I'd probably suggest you take a look at the umbraco docs regarding how the new partials view engine works aswell as some tips for converting your old code to the newer view engine:

    http://our.umbraco.org/documentation/Reference/Templating/Macros/Partial-View-Macros/

    Have a read of that, and see if it makes any sense.

    Many thanks

    Matt

  • Peter Cort Larsen 421 posts 1038 karma points
    Jun 18, 2014 @ 15:36
    Peter Cort Larsen
    0

    So i need to change the entire solution to using MVC?

     

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Jun 18, 2014 @ 15:43
    Matt Brailsford
    100

    You shouldn't need to switch everything. If you stick with using Macros, the docs say you can use partial view macros with webforms too. It does mean you'd have to change your old razor macros to the new partial macros though.

    If you see the docs page here (http://our.umbraco.org/documentation/reference/templating/macros/) you'll see that the older macro engine has been deprecated, hence why Vorto doesn't support it.

    TL;DR - You don't have to update EVERYTHING, but you will need to update your macros.

    Many thanks

    Matt

  • Peter Cort Larsen 421 posts 1038 karma points
    Jun 18, 2014 @ 16:05
    Peter Cort Larsen
    0

    YES YES, you are right.

    It works, fantastic.

    You are the best. YUHUUU.

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Jun 18, 2014 @ 16:08
    Matt Brailsford
    0

    Sweeet!

    Glad you got it working :)

    Many thanks

    Matt

Please Sign in or register to post replies

Write your reply to:

Draft