Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi
I am replying here as your code broke the topic, not sure how!
I would say that instead of trying to find Home and then listing the children, use Umbraco.TypedContentAtRoot(); and list the Children, try to stay away from DescendantsOrSelf as that may return more pages than you need in the navigation.
Also, try and use IsVisible or Visible for those pages that are published.
Thanks
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.
Navigation List Error from Youtube vide How to Build ..Part 5
Hi I'm following Paul Seal and struggeling with a navigationlist https://www.youtube.com/watch?v=zRDHK_isHCQ I have I SiteLayoutController and render it to an Partial View and i get an Error CS1660 Cannot convert lambda expression to type 'string' because it is not a delegate type.
I have changed from Model to currentpage but get an error on x.DocumentTypeAlias I have tested to inster using Umbraco.Web but it dosen't help
Can someone help me!
The Code IPublishedContent homePage = CurrentPage.AncestorOrSelf(1).DescendantsOrSelf().Where(x => x.DocumentTypeAlias == "Home").FirstOrDefault();
The issue is with your Where clause.
The error you get is Error CS1660 Cannot convert lambda expression to type 'string' meaning your expression x => x.DocumentTypeAlias == "Home" is not a string.
Try ..Where("DocumentTypeAlias == \"Home\"")
Thanks! But it dosen't work se error below
If I use this code it works, but i prefer the other one
const int HOMEPAGEPOSITIONINPATH = 1; int homePageId = int.Parse(CurrentPage.Path.Split(',')[HOMEPAGEPOSITIONINPATH]); IPublishedContent homePage = Umbraco.Content(homePageId);
Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 47: Line 48: List
If you post the entire code here I will take a look.
Thanks a lot Here is my code
/C
//Masterpage @inherits Umbraco.Web.Mvc.UmbracoTemplatePage @using System.Web.Optimization @{ Layout = null; }
//SiteLayoutController using System; using System.Collections.Generic; using System.Web.Mvc; using Umbraco.Web.Mvc; using Umbraco.Web; using Umbraco.Core.Models; using konferens.Web.Models; using System.Runtime.Caching; using System.Linq;
namespace konferens.Web.Controls { public class SiteLayoutController:SurfaceController { private const string PARTIALVIEWFOLDER = "~/Views/Partials/SiteLayout/";
}
//NavigationLink.cs namespace konferens.Web.Models { public class NavigationLink { public string Text { get; set; } public string Url { get; set; } public bool NewWindow { get; set; } public string Target { get { return NewWindow ? "_blank" : null; } } public string Title { get; set; }
}
//NavigationListItem.cs using System.Collections.Generic; using System.Linq;
namespace konferens.Web.Models { public class NavigationListItem { public string Text { get; set; } public NavigationLink Link { get; set; } public List
} //Header PartialView @inherits Umbraco.Web.Mvc.UmbracoViewPage<>
@helper RenderChildItems(List
}