Return to Snippet

Revision: 14363
at October 1, 2009 01:48 by jink


Updated Code
/// <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);
}

Revision: 14362
at June 1, 2009 17:13 by jink


Initial Code
/// <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>
/// <returns>A correct URL for the tab if the tab is found, otherwise an empty string.</returns>
private string GetUrlForTab(string tabName, ArrayList portalTabs)
{
	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);
	}
	return "";
}
/// <summary>
/// Returns a list of the portal tabs from DNN.
/// </summary>
/// <returns></returns>
private ArrayList GetPortalTabsFromDNN()
{
	return DotNetNuke.Common.Globals.GetPortalTabs(PortalSettings.DesktopTabs, false, true);
}

Initial URL

                                

Initial Description
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.

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

Initial Tags
url, aspnet

Initial Language
C#