Module Controller Integration

When initializing, NavXp iterates all modules installed on current portal and checks if the corresponding Business Controller class implements two special methods:
  • Dictionary<string, string> NavXp_ActiveDataSources()
    NavXp invokes this method to get a list of data sources the module exposes. Each entry in the dictionary represents an (id, title) pair. Remember that a data source is the smaller unit that can be used in NavXp Profile Editor, so you'll use this method to export multiple Lists of links (for example, one for each page module of the given type). See example below for more info.

  • List<Dictionary<string, object>> NavXp_ActiveDataSourceItems(string activeDataSourceId)
    NavXp invokes this method to get a list of links to display in menu where activeDataSourceId is the id returned by NavXp_ActiveDataSources call above. Each dictionary in the list has the following keys:

  • caption - what to display in the menu
  • id - this should be as much as possible a globally unique ID for NavXp
  • url - where to redirect to when link is clicked
  • subitems - this is a list of dictionaries similar to the root one that represents the child items

We did this integration with Lists and Dictionaries instead of concrete classes because we didn't want to add any dependency for the 3rd party module, nor have it depend on NavXp assembly presence.

Things are probably simpler than they sound. Please see the example below for more information:

public class MyController { .................................................................. public Dictionary<string, string> NavXp_ActiveDataSources() { return new Dictionary<string, string>() { {"id1", "Active Data Source 1"}, {"id2", "Active Data Source 2"}, {"id3", "Active Data Source 3"} }; } public List<Dictionary<string, object>> NavXp_ActiveDataSourceItems(string activeDataSourceId) { List<Dictionary<string, object>> ds = new List<Dictionary<string, object>>(); ds.Add( new Dictionary<string, object>() { { "caption", "My Link" }, { "id", "1" }, { "url", "http://yoursite.here" }, { "subitems", new List<Dictionary<string, object>>() { new Dictionary<string, object>() { { "caption", "My Sub Link" }, { "url", "http://yoursite.here" } } } } } ); ds.Add( new Dictionary<string, object>() { { "caption", "2nd Link" }, { "url", "http://yoursite.here" } } ); return ds; } .................................................................. }
Comments