Copied to clipboard

Flag this post as spam?

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


  • David Dunhill 4 posts 25 karma points
    Oct 31, 2014 @ 14:09
    David Dunhill
    0

    Related Link

    Hello

    I've been working with Related Links today and for what ever reason the examples here weren't working for me. The examples use DynamicXML but I when I tried it the return data is always empty. Anyway below is my fix in case anyone gets stuck on this too.

    Basically switch JArray for DynamicXML and fix the case on newwindow to newWindow.

      var homeNode = Model.Content.AncestorOrSelf(1);
      var columnOne = homeNode.GetPropertyValue<JArray>("columnOne");
      @if (columnOne.Any())
      {
        <ul>
        @foreach (dynamic item in columnOne)
        {
          var linkUrl = (item.type.Equals("internal")) ? Umbraco.NiceUrl(int.Parse(item.link)) : item.link;
          var linkTarget = (item.newWindow.Equals("1")) ? " target=\"_blank\"" : string.Empty;
          <li><a href="@linkUrl"    @Html.Raw(linkTarget)>@item.title</a></li>
        }
        </ul>
      }
    

    Cheers

    D

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Oct 31, 2014 @ 14:13
    Jeavon Leopold
    0

    Hi David,

    Did you find the samples in the documentation here?

    Jeavon

  • David Dunhill 4 posts 25 karma points
    Oct 31, 2014 @ 15:04
    David Dunhill
    0

    Hi

    This is the page I landed on from google link

    D

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Oct 31, 2014 @ 15:08
    Jeavon Leopold
    0

    Ah yes, that's the v4/v6 version. Always goto here for v7 property editor documentation.

    Jeavon

Please Sign in or register to post replies

Write your reply to:

Draft