Custom menu - access custom properties for menu items
I am trying to build a menu in Umbraco where the user can mark pages/menu-items with a different color.
I have a custom property (checkbox) called "MarkAsRed" on the document type I use for all the nodes on my page.
The code below gives me an error on @page.MarkAsRed. However @home.MarkAsRed works and gives me a value for the root node.
What is missing so I can get the correct value for each node in the menu?
"Compiler Error Message: CS1061: 'Umbraco.Core.Models.IPublishedContent' does not contain a definition for 'MarkAsRed' and no extension method 'MarkAsRed' accepting a first argument of type 'Umbraco.Core.Models.IPublishedContent' could be found (are you missing a using directive or an assembly reference?)"
The home node is accessed dynamically but your children are accessed strongly typed. That's why you can write @home.MarkAsRead and not @page.MarkAsRead.
So for accessing custom properties, write the following instead:
@page.GetPropertyValue("markAsRead").
Custom menu - access custom properties for menu items
I am trying to build a menu in Umbraco where the user can mark pages/menu-items with a different color.
I have a custom property (checkbox) called "MarkAsRed" on the document type I use for all the nodes on my page.
The code below gives me an error on @page.MarkAsRed. However @home.MarkAsRed works and gives me a value for the root node.
What is missing so I can get the correct value for each node in the menu?
"Compiler Error Message: CS1061: 'Umbraco.Core.Models.IPublishedContent' does not contain a definition for 'MarkAsRed' and no extension method 'MarkAsRed' accepting a first argument of type 'Umbraco.Core.Models.IPublishedContent' could be found (are you missing a using directive or an assembly reference?)"
Hi Leopold.
The home node is accessed dynamically but your children are accessed strongly typed. That's why you can write @home.MarkAsRead and not @page.MarkAsRead.
So for accessing custom properties, write the following instead: @page.GetPropertyValue("markAsRead").
If you want to read more about strongly/dynamic models there is a great article by Dave Woestenborghs: http://24days.in/umbraco/2015/strongly-typed-vs-dynamic-content-access/
Have a good day!
is working on a reply...