Quantcast
Channel: ActiveTopics
Viewing all articles
Browse latest Browse all 72689

Loop through the Multi node Tree Picker and also loop through a different Doc Type to display the data

$
0
0

I can successfully render content from a different Doc Type using x.ContentType.Alias == "cases", however, I also want the ability to use the Multinode Tree Picker so the editor can reorder the results. Inside of my cases Doc Type I have a text field for pageTitle.

At the moment, my foreach renders the results twice as it looks through the Tree Picker, sees there are two items and then also loops through the foreach() for the .Alias where there are two published items.

I thought a way around this would be to add an extra Where() and compare it to the Name() of the item in typedMultiNodeTreePicker but I get an error:

Operator '==' cannot be applied to operands of type 'method group' and 'string'

Any ideas on how I can do this?

Full code:

@{
var typedMultiNodeTreePicker = Model.Value<IEnumerable<IPublishedContent>>("caseStudies");
if (typedMultiNodeTreePicker != null)
{
    foreach (var item in typedMultiNodeTreePicker)
    {

        <a href="@item.Url()" style="font-size:30px;">

            @item.Name()

            @{

                var works = Model.Children().Where(x => x.ContentType.Alias == "cases" && x.ContentType.Name == item.Name());

                foreach (var work in works)
                {
                    @work.Value("pageTitle")

                    <br>

                }

            }

        </a>

        }
      }
}

Thanks


Viewing all articles
Browse latest Browse all 72689

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>