Posted on 25/09/2023 18:31:21
Hi Caro
On a page, choose properties - there are a number of options. It is unclear if you are using Swift or not?
- If you use Swift, Swift pages (using Swift_Page item type) already have an item type used for the page that contains the field "Icon" that has been defined in the item types section of settings.You can add your own icons
- Also on page properties, there is an image field that can also be used - that is a standard field so not related to an item type for that page. See screen dump below.
When rendering the navigation, you can call the GetNavigation to get a Navigation viewmodel for all pages on level 1+2 like this:
var dropdownNavigation = GetNavigation(new() { StopLevel = 2, ExpandMode = Dynamicweb.Frontend.Navigation.ExpandMode.All });
See the docs for navigation here: https://doc.dynamicweb.dev/documentation/implementing/ssr/designs-layouts.html#example-of-a-top-navigation - checkout the "Top-dropdown navigation " section.
When looping the navigation nodes you have a NavigationTreeNodeViewModel - it will have a PageId property. Use Dynamicweb.Content.Pages.GetPage to get hold of the page instance where you can find the image used:
var page = Dynamicweb.Content.Services.Pages.GetPage(node.PageId);
var image = Page.TopImage