/ Published in: C#
Use this code to pull a DotNetNuke URL from a tab name. We use this to replace "?tabname=blah" type URLs which do NOT transfer language info.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/// <summary> /// Gets a correct DNN URL for a given tab name. /// </summary> /// <param name="tabName">TabName to find a URL for. This TabName should match the name of the PAGE you want to redirect to.</param> /// <param name="portalTabs">Cached pull of Globals.GetPortalTabs, if null this method will pull the portal tabls.</param> /// <param name="additionalParams">Additional parameters to put in URL, such as "id=0"</param> /// <returns>A correct URL for the tab if the tab is found, otherwise an empty string.</returns> private string GetUrlForTab(string tabName, List<DotNetNuke.Entities.Tabs.TabInfo> portalTabs, params string[] additionalParams) { if (portalTabs == null) portalTabs = GetPortalTabsFromDNN(); foreach (DotNetNuke.Entities.Tabs.TabInfo t in portalTabs) { if (string.Compare(t.TabName, tabName, true) == 0 || string.Compare(t.Title, tabName, true) == 0) return DotNetNuke.Common.Globals.NavigateURL(t.TabID, "", additionalParams); } return ""; } /// <summary> /// Returns a list of the portal tabs from DNN. /// </summary> /// <returns></returns> private List<DotNetNuke.Entities.Tabs.TabInfo> GetPortalTabsFromDNN() { return DotNetNuke.Entities.Tabs.TabController.GetPortalTabs(0, -1, false, true); }