Copied to clipboard

Flag this post as spam?

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


  • jpdel3000 7 posts 27 karma points
    Feb 26, 2020 @ 17:33
    jpdel3000
    0

    Problems with object and definition of Where

    Hello guys! I'm kinda new to Umbraco, and here also, but i'm following a tutorial to make a begginers website, and I followed every step along the way. But unfortunatly, the video i'm seeing doesn't has this error, and I do.

    List<NavigationList> navList = null;
            var subPages = page.Children.Where("Visible");
    

    The error that appears is " 'object' does not contain a definition for 'Where' ".

    Is there a way to fix it?

    PS: It's for a dynamic Header with the pages

  • Joep 96 posts 698 karma points
    Feb 27, 2020 @ 07:43
    Joep
    0

    Hi,

    Try using this Page.Children.Where(x => x.IsVisible)

    -Joep

  • jpdel3000 7 posts 27 karma points
    Feb 27, 2020 @ 09:02
    jpdel3000
    0

    It didn't work, same error :(

  • Joep 96 posts 698 karma points
    Feb 27, 2020 @ 09:19
    Joep
    0

    Hi,

    Sorry it is IsVisible() forgot that it was a method.

    -Joep

  • jpdel3000 7 posts 27 karma points
    Feb 27, 2020 @ 09:22
    jpdel3000
    0

    For what i've read, it is a problem on "using System.Linq" but i do have that on my project, just says it's unnecessary dont know why

  • Kevin Jump 2309 posts 14673 karma points MVP 7x c-trib
    Feb 27, 2020 @ 09:25
    Kevin Jump
    0

    Hi,

    I think you are following the same video as in this post.: https://our.umbraco.com/forum/using-umbraco-and-getting-started/101110-code-error

    Its quite a long thread but the basics are in this reply: https://our.umbraco.com/forum/using-umbraco-and-getting-started/101110-code-error#comment-317042

  • jpdel3000 7 posts 27 karma points
    Feb 27, 2020 @ 09:37
    jpdel3000
    0

    Hi Kevin,

    The previous error dissapeared, but now i'm getting "Value cannot be null Parameter name: Collection", my code is as follows (as the video teaches me)

    public List<NavigationList> GetNavigationModel()
        {
    
            int pageId = int.Parse(CurrentPage.Path.Split(',')[1]);
            IPublishedContent pageInfo = Umbraco.Content(pageId);
            var nav = new List<NavigationList>
            {
                new NavigationList (new NavigationLinkInfo(pageInfo.Url,pageInfo.Name))
            };
    
            nav.AddRange(GetSubNavigationList(pageInfo));
    
            return nav;
    
        }
    

    The error says it's in the line that has:

    nav.AddRange(GetSubNavigationList(pageInfo));
    
  • Kevin Jump 2309 posts 14673 karma points MVP 7x c-trib
    Feb 27, 2020 @ 09:41
    Kevin Jump
    0

    Hi

    That might be because there are no items in the navigation,

    On your GetSubNavigationList method i would change

        List<NavigationList> navList = null;
    

    to

        List<NavigationList> navList = new List<NavigationList>(); 
    

    this will mean the list is always something even if it's empty. and that will stop the next bit throwing an error when there are no pages to put in the list.

    I've had a google, i think the main problem is the video you are looking at was for Umbraco 6/7 and in Umbraco 8 you can't do 'dynamics' anymore :( so anywhere where 'dynamic' is used the code is going to need to be re-written

  • jpdel3000 7 posts 27 karma points
    Feb 27, 2020 @ 09:46
    jpdel3000
    0

    Is there any begginers tutorial for 8 then? because not knowing how to do things, is hard :/

Please Sign in or register to post replies

Write your reply to:

Draft