Hi all,
I am having trouble trying to get tabs urls. Here is my scenario:
I have a main portal (id 0) that has a home page (tabid 20). My dev environment has this portal mapped to "http://dnndev.me".
There is a second portal named Finance thas is configured to be a subdirectory, so this portal is responding on "http://dnndev.me/finance"
Now I am running code in the finance portal and want to get the url to the homepage of the portal 0.
My code is as follows:
int portalId=0; var portal = DotNetNuke.Entities.Portals.PortalController.Instance.GetPortal(portalId); var homeTabId = portal.HomeTabId; //Returns 20 - OK TabInfo tb = DotNetNuke.Entities.Tabs.TabController.Instance.GetTab(homeTabId, portalId); var homeTabUrl = DotNetNuke.Common.Globals.NavigateURL(tabId); //Returns "http://dnndev.me/finance/Home" - Wrong homeTabUrl = tb.FullUrl; //Returns "http://dnndev.me/finance/Home" - Wrong
I was expecting the previous code to return something like "http://dnndev.me" or "http://dnndev.me/Home" but it seams it is generation the url using the current portal context instead of using the portal info specified in the secong argument of GetTab.
Looking on the source code for the TabInfo class - https://github.com/dnnsof...bInfo.cs#L368 - I suspect that the url returned does not take into account the portal that the tab belongs to.
Anyone has any clues on how to overcome this or any best practice on how to achieve this?
Thanks! Miguel
You'll want to use the NavigateURL overload that takes an PortalSettings instance, and you'll need to get that instance via the PortalSettings constructor that takes a PortalAliasInfo instance.
NavigateURL
PortalSettings
PortalAliasInfo
Hope it helps!
Thanks Brian!
It worked as expected using yout method.
var portalAliasInfoList = (new DotNetNuke.Entities.Portals.PortalAliasController()).GetPortalAliasesByPortalId(portalId); var portalSettings = new DotNetNuke.Entities.Portals.PortalSettings(tabId, portalAliasInfoList.First()); return DotNetNuke.Common.Globals.NavigateURL(tabId, portalSettings, "");
I am still using the obsolete Globals.NavigateUrl since I am using this code inside a skin object. I will revise this in the future.
Cheers
These Forums are dedicated to the discussion of DNN Platform.
For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:
Awesome! Simply post in the forums using the link below and we'll get you started.