Use image from a page custom field in navigation widget
Hi,
I need to display a navigation menu with a different image for each menu item, I don't want to create a custom widget for that because except for this image all the needed functionalities are presents in the out of the box navigation widget.
Is there a way to access to the page custom fields inside the out of the box navigation widget?
Thanks in advance for your help.
David.
Hi David, u can access page custom fields in this way (example of template for navigation widget for Feather)
@model INavigationModel@using Prototype.Sitefinity.SitefinityControllers@using Telerik.Sitefinity.Frontend.Mvc.Helpers@using Telerik.Sitefinity.Frontend.Navigation.Mvc.Models;@using Telerik.Sitefinity.Modules.Libraries@using Telerik.Sitefinity.Pages.Model@using Telerik.Sitefinity.Web@foreach (var node in Model.Nodes) PageSiteNode pageNode = node.OriginalSiteMapNode as PageSiteNode; var thumbnail = ((Telerik.Sitefinity.Libraries.Model.Image) pageNode.GetCustomFieldValue("Image")); <div>@node.Title <span> @if (thumbnail != null) <img src="@thumbnail.ResolveThumbnailUrl(true)" alt="@thumbnail.AlternativeText"> </span> </div>
Please let me know if you need example for non-Feather widget
Thank you for your help Victor it works perfectly.
I want to add a short text as a header for some nodes , I have added a custom field ( Header_Text) as a short text . but I am unable to use it within the MVC navigation control. please advise.