Forum


HomeHomePremiumPremiumDevelopmentDevelopmentLinking from one page to another.Linking from one page to another.
Previous
 
Next
New Post
10/17/2013 10:20 AM
 

I am looking at passing info between a couple modules and wanted to know the proper way to create the URLs to the destination page.

I am currently using

DotNetNuke.Common.Globals.NavigateURL()

This function wants a TabId if you aren't going to the current module.  Where can I find the Tab Id in DNN?  I can find the tab id by using NavigateURL on the destination page, looking at the URL it produces, then copying it from the address but this seems clunky and I feel like I should be able to look up this info while logged in as an admin to DNN.

Is this the correct way to link from one page to another?  My alternative method is to simply format a string: http://mysite.com/mymodule.aspx?myVar=VALUE but this didn't seem to fit within the DNN mentality too well and wanted to know the proper way to do this.

 Thanks,

 

"Look to the sky as much as the screen!"

 
New Post
10/17/2013 4:10 PM
 

Andy,

When it comes to linking to another module's view, you can't make assumptions about how users will add the module and to which page.  One thing I have done is got a list of all instances of a particular module on a portal:

ModuleController mc = new ModuleController();

ArrayList oModules = mc.GetModulesByDefinition(portalID, "Module Definition Name");

Once you have this list of module instances and you decide which one you want to link to, get the TabID (example: oModules[0].TabID) and use NavigateUrl().

 
New Post
10/21/2013 4:13 PM
 

Thanks Scott, 

I see where you are going with your answer and appreciate the info as helps me see what's going on under the hood. 

I probably didn't explain my situation so well which happens all too often when trying to abstract a problem.  Basically I needed a way to link my product page to my shopping cart page so I could add products.  The base URL to the shopping cart will be the same throughout the entire site.  The products are managed externally so the links need to be formed dynamically with the product id.

I will only have one cart on my site, so I decided that the module settings looked like the easiest place to put the info.  I added a module setting to hold the cart url.  I used the UpdateModuleSetting() method so the setting can be shared anywhere I use my module. 

This works okay but I really want to use a portal level setting so that if I create multiple modules that all need to point to the same shopping cart, you only need to adjust the setting in one location.  I could do this by creating my own settings table but if I needed to do this, it might be easier and quicker just to set it in multiple locations. 

I saw in the video where UpdateTabModuleSetting() connects a setting to a instance of a module and UpdateModuleSetting() updates a setting that is shared by all instances of a module.  Is there an equivalent that is set at the portal level?  I did a little poking around and saw that there is a PortalModuleBase() object that has a settings variable.  Is this the key?

 
New Post
10/22/2013 8:49 AM
 

I tested a couple more ideas and finally landed on the solution, the PortalController Class.

Several classes have been used for this in different versions of DNN but the DNN 7 way looks to be using the functions provided by DotNetNuke.Entities.Portals.PortalController class.

There are 3 methods to get a single setting value, GetPortalSetting(), GetPortalSettingAsBoolean(), and GetPortalSettingAsInteger(). 

There is one method to update, UpdatePortalSetting().

I gave this a little test and it retained my value so it appears to be working.  I haven't tested this across multiple modules but seeing that these functions accept input that includes the portal id and not the module id, I am guessing the info will be shared.

 
Previous
 
Next
HomeHomePremiumPremiumDevelopmentDevelopmentLinking from one page to another.Linking from one page to another.



Try FREE
30 days money back guaranteed