Copied to clipboard

Flag this post as spam?

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


  • Aleksey Gerasimov 31 posts 95 karma points
    Jan 22, 2016 @ 17:30
    Aleksey Gerasimov
    0

    Can't build a entity request

    Hi There,

    This is my scema of site

    Site
      Parent1
        LandingPage
        Collection1
          meta1
          meta2
        Collection2
          meta6
          meta7
      Parent2
        LandingPage
        Collection1
           meta3
           meta4
           meta5
        Collection2
          meta8
          meta9
    

    So, i need get "meta"s on LandingPage for appropriate Parent. I've get meta from Collection1 as

    CurrentPage.AncestorsOrSelf(2)[0].FirstChild("Collection").FirstChild("Collection").Children("Meta").Where("Visible");
    

    Currently, I'm not understand how I can get meta from Collection2, Collection3 and etc.

    Have any ideas? May be I can do it with names of collection?

  • Alex Skrypnyk 6182 posts 24283 karma points MVP 8x admin c-trib
    Jan 23, 2016 @ 13:48
    Alex Skrypnyk
    0

    Hi Aleksey,

    Yes, you can do that names of collections, but it's little bit hardcoded.

    Can you describe more, you need all 'meta' from nearest parent on the Landing page ?

    Thanks, Oleksandr

  • Aleksey Gerasimov 31 posts 95 karma points
    Jan 25, 2016 @ 14:11
    Aleksey Gerasimov
    0

    I need an arrays of 'meta' from nearest parent on Landing page. I mean one array for Collection1, second array for Collection2 and etc.

    For my case it's ok use a bit hardcoded by name. But I realy want to avoid hardcoded by Id.

  • Yasir Butt 162 posts 372 karma points
    Jan 23, 2016 @ 21:07
    Yasir Butt
    0

    I think you can try this one if you are on landingpage. so you can get all the meta under same parent.

    Model.Content.Parent().Descendants("Meta").Where(x=>x.GetPropertyValue<bool>("visible")).
    

    If you want to get meta under specific collection then i will make a property called MetaCollectionPage as ContentPicker then

    var collectionPage  =    Umbraco.TypedContent( Model.Content.GetPropertyValue<int>("metaCollectionPage"));
    
    var metas = collectionPage.Children; // these are metas
    
  • Aleksey Gerasimov 31 posts 95 karma points
    Jan 25, 2016 @ 14:19
    Aleksey Gerasimov
    0

    Can I write something like

    Model.Content.Parent().Descendants().Where(x.GetPropertyValue<string>("Name").Contains("Collection1Name")).Descendants("Meta").Where(x=>x.GetPropertyValue<bool>("visible"))
    

    ?

  • Alex Skrypnyk 6182 posts 24283 karma points MVP 8x admin c-trib
    Jan 25, 2016 @ 14:52
    Alex Skrypnyk
    0

    Aleksey,

    As I understand you need something like:

    var a = Model.Content.Parent.Descendants().FirstOrDefault(x => x.GetPropertyValue<string>("Name").Contains("Collection1Name")).Descendants("Meta").Where(x => x.IsVisible());
    
  • Aleksey Gerasimov 31 posts 95 karma points
    Jan 25, 2016 @ 15:27
    Aleksey Gerasimov
    0

    For same requests I get exception:

    Cannot use a lambda expression as an argument to a dynamically dispatched operation without first casting it to a delegate or expression tree type

  • Alex Skrypnyk 6182 posts 24283 karma points MVP 8x admin c-trib
    Jan 25, 2016 @ 15:32
    Alex Skrypnyk
    0

    Aleksey do not use dynamic. I think it's not perfect solution for views.

  • Yasir Butt 162 posts 372 karma points
    Jan 25, 2016 @ 14:14
    Yasir Butt
    0

    Check the second part of my solution

  • Aleksey Gerasimov 31 posts 95 karma points
    Jan 25, 2016 @ 15:31
    Aleksey Gerasimov
    0

    I'm not understand for that I need add a special field for that. Also, it's born a lot of question from moderators. I prefer use filter collection by name, but all my requests failed with error:

    Cannot use a lambda expression as an argument to a dynamically dispatched operation without first casting it to a delegate or expression tree type

  • Yasir Butt 162 posts 372 karma points
    Jan 25, 2016 @ 20:34
    Yasir Butt
    0

    Aleksey!

    This is one of the easiest thing. i dont know why are you making it so complex and hard coded

    Do you have skype id. give it to me we resolved it in a minute

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies