Posted By

jink on 06/01/09


Tagged

url aspnet DotNetNuke


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

umang_nine


DotNetNuke: Pull URL for a given tab NAME. (DNN 5.1+)


 / 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.

  1. /// <summary>
  2. /// Gets a correct DNN URL for a given tab name.
  3. /// </summary>
  4. /// <param name="tabName">TabName to find a URL for. This TabName should match the name of the PAGE you want to redirect to.</param>
  5. /// <param name="portalTabs">Cached pull of Globals.GetPortalTabs, if null this method will pull the portal tabls.</param>
  6. /// <param name="additionalParams">Additional parameters to put in URL, such as "id=0"</param>
  7. /// <returns>A correct URL for the tab if the tab is found, otherwise an empty string.</returns>
  8. private string GetUrlForTab(string tabName, List<DotNetNuke.Entities.Tabs.TabInfo> portalTabs, params string[] additionalParams)
  9. {
  10. if (portalTabs == null)
  11. portalTabs = GetPortalTabsFromDNN();
  12. foreach (DotNetNuke.Entities.Tabs.TabInfo t in portalTabs)
  13. {
  14. if (string.Compare(t.TabName, tabName, true) == 0 || string.Compare(t.Title, tabName, true) == 0)
  15. return DotNetNuke.Common.Globals.NavigateURL(t.TabID, "", additionalParams);
  16. }
  17. return "";
  18. }
  19. /// <summary>
  20. /// Returns a list of the portal tabs from DNN.
  21. /// </summary>
  22. /// <returns></returns>
  23. private List<DotNetNuke.Entities.Tabs.TabInfo> GetPortalTabsFromDNN()
  24. {
  25. return DotNetNuke.Entities.Tabs.TabController.GetPortalTabs(0, -1, false, true);
  26. }

Report this snippet  

You need to login to post a comment.