Copied to clipboard

Flag this post as spam?

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


  • Garrett Fisher 341 posts 496 karma points
    Sep 16, 2015 @ 20:51
    Garrett Fisher
    0

    Related Links Field Saved As String Instead of XML

    Hi,

    Having a problem getting some fields to work in Umbraco 7.2.8 that used to be uComponents URL Picker fields. I'm almost completely done with an upgrade path all the way from 4.7.2 and this is my final issue! I've converted these fields over to the built-in "Related Links" data type, re-entered all the content and republished, but when I am attempting to show the values in XSLT I am getting nothing.

    Existing code sample:

    <xsl:variable name="homenode" select="$currentPage/ancestor-or-self::Home"/>
    <a href="{$homenode/fieldName/url-picker/url}" target="_blank">
         <xsl:value-of select="$homenode/fieldName/url-picker/link-title"/>
    </a>
    

    I don't know what to change the code to say here because when I write out a:

    <xsl:copy-of select="$homenode/fieldName"/>
    

    I get:

    <fieldName><url-picker mode="URL"><new-window>False</new-window><node-id></node-id><url>http://www.purina.com/general/terms.aspx</url><link-title>Terms and Conditions</link-title>
    </url-picker></fieldName>
    

    It's just a string though -- it's not actual XML -- so I can't parse the elements like I normally would in xPath. Seems to me there shouldn't even be these tags stored in there in the first place anymore now that it's not a URL Picker field. If I have to fix this in the database, what format is Related Links supposed to save in?

    Ideas?

    Thanks,

    Garrett

  • Janae Cram 63 posts 437 karma points MVP 5x c-trib
    Sep 16, 2015 @ 21:02
    Janae Cram
    0

    Related links switched to returning JSON (specifically a JArray) when they moved to v7. I haven't worked with them in XSLT, but there's some documentation on how they work with MVC here: https://our.umbraco.org/documentation/getting-started/backoffice/property-editors/built-in-property-editors/related-links :)

  • Chriztian Steinmeier 2732 posts 8346 karma points MVP 5x admin c-trib
    Sep 16, 2015 @ 21:12
    Chriztian Steinmeier
    0

    Hi Garrett,

    If I were to guess about this, I'd say that the "XML" you're seeing is the result of changing the property editor — have you tried changing the value (e.g. pointing to another page) and then saving the property? Does it change the XML string or does it switch to just an id, a CSV list of ids, or perhaps JSON?

    /Chriztian

  • Garrett Fisher 341 posts 496 karma points
    Sep 17, 2015 @ 13:12
    Garrett Fisher
    0

    Hey, thanks a lot, guys, for replying.... Chriztian! What up, man?!

    I have an update. More bad news, sadly. As it turns out, these Related Links fields aren't saving to the database at ALL. I was fooled by Angular into thinking I was putting in values but if I navigate to another page and then come back, the fields are indeed empty.

    What I am seeing on the front end in my <xsl:copy:of> is just the legacy/remnant data from the old uComponents URL Picker days.

    Any ideas why these are not saving? There is no error. Log:

    2015-09-17 09:10:58,761 [57] INFO  Umbraco.Core.Publishing.PublishingStrategy - [P12112/T35/D4] Content 'Home' with Id '1055' has been published.
    2015-09-17 09:11:02,816 [57] INFO  umbraco.content - [P12112/T35/D4] Save Xml to file...
    2015-09-17 09:11:02,889 [57] INFO  umbraco.content - [P12112/T35/D4] Saved Xml to file.
    

    Weird, ha?

  • Garrett Fisher 341 posts 496 karma points
    Sep 17, 2015 @ 13:52
    Garrett Fisher
    0

    Here is the snippet inside that field in the cmsContentXml:

    <![CDATA[<url-picker mode="URL">
      <new-window>False</new-window>
      <node-id></node-id>
      <url>http://www.purina.com/</url>;
      <link-title>Purina</link-title>
    </url-picker>]]>
    

    And again, it is not being overwritten in the database upon save/publish.

    //Garrett

  • Chriztian Steinmeier 2732 posts 8346 karma points MVP 5x admin c-trib
    Sep 17, 2015 @ 19:55
    Chriztian Steinmeier
    0

    Yay :-)

    Have you tried explicitly saving a different value? I've seen on several occasions that if I start filling in a field and the autocomplete kicks in, that I need to type every single letter for the change to actually kick in (if the value is the same as it was) - Angular seems to handle the autocompletion as "okay, he didn't change anything - we don't need to persist anything then".

    If that's not the case, then you have some data-corruption on your hands, I guess :(

    /Chriztian

  • Garrett Fisher 341 posts 496 karma points
    Sep 17, 2015 @ 20:17
    Garrett Fisher
    0

    Indeed.

    No matter what I did, I was just not able to get those values to overwrite -- autocomplete not the issue. So naturally, I decided to get off the lazy programmer couch and blow away the fields in the doctype utilizing this data type / property editor, save, re-create and re-save and... voila.

    Thinking about leveraging the Multi Url Picker package instead now but the last time I installed that somewhere I remember it creating a million empty instances in my documents invoking it. You familiar with that weirdsie? I'll get a screenshot of it next chance I get.

    Thanks again Chriztian -- you're always very helpful.

    //Garrett

Please Sign in or register to post replies

Write your reply to:

Draft