Menu Data Source
8 min
overview the menu data source fetches menu items from the catalog api menus are defined and managed by editors in the cms, and this data source makes them available to navigation components in the app when to use this use menu when navigation items should be controlled by editors through the cms rather than hardcoded in views json if the navigation is static and never changes, use custom instead basic example { "type" "menu", "contextkey" "mainnav", "filter" { "name" { "value" "main navigation" } } } configuration type specific properties property type default description filter object — selects which menu to load (server side, filters on the menu itself) itemfilter object — filters items within the loaded menu (client side, evaluated per item) fetchoptions object — optional fetch request options (e g totalcount false ) for common properties ( contextkey , limit , batchsize , etc ) see todo insert link to data sources overview link filter properties (menufilter — selects the menu) filter key type description name stringfilter match menus by name properties mapfilter match menus by custom property supports and and or does not support condition — use itemfilter for conditional logic itemfilter properties (storefrontmenuitemfilter — filters items within the menu) filter key type description name stringfilter include only items matching this name parentid stringfilter include only items under a specific parent properties mapfilter filter items by custom property supports and , or , and condition advanced features filtering items by condition use itemfilter with a condition to hide menu items based on context { "type" "menu", "contextkey" "mainnav", "filter" { "name" { "value" "main navigation" } }, "itemfilter" { "condition" { "value" "$context user isloggedin", "operation" "equals", "comparevalue" "true" } } } testing notes / edge cases menu is selected by filter name there is no menuid property a wrong name returns an empty list silently filter vs itemfilter filter runs server side to select which menu to load itemfilter runs client side per item only itemfilter supports condition item order items are sorted client side by their sortindex field — the api does not guarantee order the final order always reflects the sortindex set in the cms editor updates menu changes are subject to maxcacheage — changes may not be immediately visible empty menu a menu with no items (or all items filtered out) returns an empty list related topics todo insert link to data sources overview linktodo insert link to custom data source link