But when I am on a page using the page document type the site produces an error.
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 8: <div class="nav navv2">
Line 9: <ul>
Line 10: @foreach (var item in Model.Content.GetPropertyValue<IEnumerable<MeganavItem>>("navigation"))
Line 11: {
Line 12: if (item.Children.Any()){
This line:
@foreach (var item in Model.Content.GetPropertyValue<>
Model.Content is equal to your current page.
You are accessing the "navigation" property each time on the page itself.
I'm guessing you have this property only available on your "Home" node.
You should determine what the "Home" node is for your current page.
Most probably, by traversing:
Model.Content.AncestorOrSelf("homeDocType")
You should directly pass it in the call (for the caching).
Cogworks Meganav - Child templates
Hi All, New to Umbraco, Just about 10 hours in and learning, Bare with me if anything is "noobish".
I have a master page, child template setup and running into issues with some inheritance etc.
Master Template has:
I am calling a partial:
This renders. In this partial I have:
I have a layout and for a navigation I call a Navigation Partial:
I am using this megaNav: https://github.com/thecogworks/meganav
And its code they provide the basic loop through and here is where I have my current issue.
At the top of this partial I have:
And the for loop:
When I am on my homepage document type
The navigation renders fine.
But when I am on a page using the page document type the site produces an error.
Source Error:
This line:
@foreach (var item in Model.Content.GetPropertyValue<>
Can anyone help me with the issue please?
Model.Content is equal to your current page. You are accessing the "navigation" property each time on the page itself. I'm guessing you have this property only available on your "Home" node. You should determine what the "Home" node is for your current page. Most probably, by traversing:
You should directly pass it in the call (for the caching).
is working on a reply...