Use image from a page custom field in navigation widget

Posted by Community Admin on 04-Aug-2018 18:03

Use image from a page custom field in navigation widget

All Replies

Posted by Community Admin on 26-Oct-2016 00:00

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.

 

Posted by Community Admin on 01-Nov-2016 00:00

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

Posted by Community Admin on 05-Nov-2016 00:00

Thank you for your help Victor it works perfectly.

Posted by Community Admin on 19-Jan-2017 00:00

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.

        

This thread is closed