Copied to clipboard

Flag this post as spam?

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


  • Scott Ritshie 35 posts 100 karma points
    Apr 07, 2015 @ 04:20
    Scott Ritshie
    0

    Getting matching values from children nodes not in same parent

    Hello,

    I'm using Umbraco 6.2.4.

    My document tree has a parent node named "Pedals" that have child nodes named "PedalCategory", each of which in turn have child nodes named "Pedal."  Each Pedal is looped through a macro and displayed on a page that lists all Pedals.  Clicking a pedal goes to that Pedal's detail page.

    There is also a parent node named "Videos" that that have child nodes named "VideoCategory", each of which in turn have child nodes named "Video."

    Let's say, for example, the current Pedal (shown in Umbraco template page) viewed has Id 1200.  I'm trying to create a loop that finds every Video with the property "pedalAssociated" whose value is 1200 and write it out to the page.  Basically, let's find all related videos for the current Pedal, Id #1200.

    Does that make sense?

    I'd prefer to write this out to an Umbraco template in a foreach loop, rather than separately through Umbraco.RenderMacro.

    Thanks for any assistance!

  • Robert J. Bullock 386 posts 405 karma points
    Apr 09, 2015 @ 22:20
    Robert J. Bullock
    0

    Hey Scott,

    Wouldn't you basically do something like this?

    var videos = VideosFolder.Descendants("Video").Where("pedalAssociated == @0", Pedal.Id);

    Where "VideosFolder" is a reference to the node where your videos are associated and "Pedal" is inside your loop of Pedals.

    Robert

  • Scott Ritshie 35 posts 100 karma points
    Apr 30, 2015 @ 21:52
    Scott Ritshie
    0

    Robert... sorry for the late reply... that was it!  I had to modify it slightly - Pedal.Id.ToString() - but otherwise, thanks!!

Please Sign in or register to post replies

Write your reply to:

Draft