Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeUsing DNN Platf...Using DNN Platf...Administration ...Administration ...URL problemsURL problems
Previous
 
Next
New Post
10/17/2008 8:24 AM
 

Hi,

I'm having some trouble understanding how to write url's for my module.  The module just hold items which are links.  If you edit the module you can set each items url from a list of all the portals tabs.  This stores the tabs id in the modules item table.  How can i convert this id to a url?  I've tried /Default.aspx?TabId=<theid> but this redirects me to the root directory.  What exactly is the url i need?

Simon

 
New Post
10/17/2008 1:22 PM
 

Simon,

check out the links module, which already provides this options and uses URLControl to enter the links as well as LinkClick.aspx to generate the Link from the ID.


Cheers from Germany,
Sebastian Leupold

dnnWerk - The DotNetNuke Experts   German Spoken DotNetNuke User Group

Speed up your DNN Websites with TurboDNN
 
New Post
10/19/2008 7:43 PM
 

Simon

If you're writing code, the actual call you're looking for is the 'DotNetNuke.Common.Globals.NavigateUrl()' call.

There are several overloads for this:

(1) NavigateUrl() : generates a url for the current tab (as defined by the current request)

(2) NavigateUrl(int tabId) : generates a url for the supplied tabId

(3) NavigateUrl(string controlKey) : generates a url for the current tab, and the specified control key.  The control key being the <key> element as defined in the module manifest file, and the module definition.  Typically, this call is used for generating 'Edit' urls, although 'EditUrl()' will do the same thing.

(4) NavigateUrl(int tabId, bool isSuperTab) : generates a url for the specified tab, and optionally allows specification that it is a 'super' tab.  The superTab switch allows the system to decide what format to present the 'admin' tabs in - generally you don't genereate 'friendly' urls for the 'super' tabs.

(5) NavigateUrl(int tabId, string controlKey) : generates a url for the speciifed tab, and the specified control key.  A combinatoin of (2) and (3).  Used for generating a link to a non-default view of a module control on another tab.

(6) NavigateUrl(string controlKey, params string[] additionalParameters) : generates a url for the current tab, including the control key and a set of optional query string parameters.   Used for generating a url for a tab where query string parameters are to be used as well.   The params string can be supplied like this : "key=value".  This will output either key=value or /key/value depending on the friendly url settings.  If the Url is for the default 'view' control, pass in ControlKey="".

(7) NavigateUrl(int tabId, string controlKey,params string[] additionalParameters) : as with (6) only with a different tabId supplied - generates the url for a tab other than the current tab.

(8) NavigateUrl(int tabid, PortalSettings settings, string controlKey, params string[] additionalParameters) :  as with (7), but allows you to pass in your own portalSettings instance.  This allows you to define different portal options, so you can either change the current language, change the portal alias, or even generate urls for a different portal altogether.  All overloads without 'portalSettings' produce Urls for the current portal, with all the current settings like the current language, current portal alias and more.  You would also supply the 'portalSettings' value for use when the portalSettings is not in the current context, such as in DotNetNuke scheduled events - the current portal settings is only created and stored in the context.items when the request is as a result of a 'user' request to the website.  Scheduled Items can be triggered by a timer and as such don't always have the 'portalSettings' instanced.  An example would be generating links for an automated email created in a scheduled task.

(9) NavigateUrl(int tabId, bool isSuperTab, PortalSettings setting, string controlKey, params string[] additionalParameters) : as with (8) but with the 'isSuperTab' switch, as described in (4).

(10) NavigateUrl(int tabid, bool isSuperTab, PortalSettings settings, string controlKye, string language, params string{} additionalParameters) : the full enchilada : you can specify all settings in (9) but also supply the language of the url.  This will insert the /language/en-Us/ parameter into the url, depending on the language and friendly url settings.

Now, the actual output of the NavigateUrl call not only depends on the overload you choose (and the parameters you pass) but also the friendly url settings.  At the top level of the friendly url settings, there is the on/off switch in host settings.  There's also the 'urlformat' attribute in the web.config, and finally you can implement a totally different friendly url provider like one of the ones I build and distribute, which will give more friendly urls, but not at the expense of ignoring the DNN API.

The problem with trying to format up the url yourself in code such as you described is that it doesn't take into account many of the different options and settings that are inherent in the Url scheme for DNN, such as language, current portal alias, control keys and whether or not the tab is an admin tab.  No DNN module developers should *ever* format up their Urls in this manner, because it will mean your module will always cause bugs for people now (who run different settings like languages etc) and in the future (when/if the DNN core decides to make an adjustment to the url scheme).

You might also like to read these blog entries of mine which deal with the subject matter in more depth:

An open letter to the DOtNetNuke developers of the workd : Please start using the FriendlyUrlProvider API for custom page names! and Designing, Structuring and Architecting DotNetNuke Modules. These cover the relationship of the DNN Manifest file entries to the urls and design of your modules, and cover generating friendly urls through better use of the FriendlyUrl API.

Understanding Urls is the key to good DNN module development - so taking the time to properly understand DNN Urls will pay off for you.

-Bruce

 
New Post
10/20/2008 4:20 AM
 

Thanks that was exactly what i was looking for.

 
New Post
10/20/2008 4:30 AM
 

Hmm i keep getting errors trying to use that.

'DotNetNuke.Common.Globals' does not contain a definition for 'NavigateUrl'

here's the code that generates thew error:

strUrl = DotNetNuke.Common.Globals.NavigateUrl(nextTabId);

I've checked nextTabId and its not giving out anything other than the required TabId. Any ideas?

 
Previous
 
Next
HomeHomeUsing DNN Platf...Using DNN Platf...Administration ...Administration ...URL problemsURL problems


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out