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

HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesFriendlyURL Method HelpFriendlyURL Method Help
Previous
 
Next
New Post
5/6/2011 10:16 PM
 
Hello,

I am creating a custom module and would like to generate Friendly URLs in one module that links to a module on another page. I think that the FriendlyURL method is what I need, but I can't really figure out how to use it to get it to do what I want. Here is my function to generate the link:

Public Function GetModulePageURL(ByVal strModuleFriendlyName As String, ByVal strNodePath As String)


            'GetModulePageURL = NavigateURL(TabId, "", "ID=" + strNodePath)


            'User the following to navigate to the desired page that has your module control on it.
            Dim mC As New ModuleController
            Dim mi As DotNetNuke.Entities.Modules.ModuleInfo

            mi = mC.GetModuleByDefinition(PortalSettings.PortalId, strModuleFriendlyName)
            If Not mi Is Nothing Then
                Dim tabTabInfo As New TabController
                Dim ti As DotNetNuke.Entities.Tabs.TabInfo
                ti = tabTabInfo.GetTab(mi.TabID, PortalSettings.PortalId, True)

                GetModulePageURL = NavigateURL(mi.TabID, "", strNodePath)

                GetModulePageURL = FriendlyUrl(ti, GetModulePageURL + "?" + strNodePath)

.......etc

This line: GetModulePageURL = NavigateURL(mi.TabID, "", strNodePath) produces: 

"http://dnn_dev/MyGarage/tabid/486/Default.aspx?ID=44/102/56/51"

The next line: GetModulePageURL = FriendlyUrl(ti, GetModulePageURL + "?" + strNodePath) produces:

"http://dnn_dev/MyGarage.aspx"

Which is close to what I want...but I thought I'd get: "http://dnn_dev/MyGarage.aspx?ID=44/102/56/51"
I guess I really don't understand what the path parameter in the FriendlyURL method is supposed to do. I see examples such as:
Example 2:
DotNetNuke.Services.Url.FriendlyUrl.FriendlyUrlProvider.Instance().FriendlyUrl(newTabController().GetTab(_tabId), "~/Default.aspx?tabid=" + _tabId "&Parameter1=xyz","My_Custom_Page_Name.aspx");


This will result in the following url:

http://localhost/Tab_Page_Title/tabid/1/Parameter1/xyz/My_Custom_Page_Name.aspx

But I don't understand why you need to put in the ~/Default.aspx.... part. Why would you want to change MyGarage.aspx to Default.aspx which is obviously not a keyword? I guess I'm just really confused as to what the Path param is supposed to do.

To be clear...this is what I'm looking for: "http://dnn_dev/MyGarage.aspx?ID=44/102/56/51"
How can I achieve this?

Second question:
And what is the custom page name about? I tried id and it generates that name, but that URL won't point to anything and will give a 404 error...I guess you need a custom parsing to convert it back first?

Thanks in Advance!
Chad
 
New Post
5/7/2011 8:17 AM
Accepted Answer 
Chad

To get exactly the same URL you need, you should pass empty string for path. Your code should be like this:


Dim
ID As String = "44/102/56/51"
Dim CorrectURL As String = String.Format("{0}?ID={1}", DotNetNuke.Common.Globals.FriendlyUrl(objTab, ""), ID)


Hope this helps!

Sergey

 
New Post
5/7/2011 9:54 AM
 
Thanks Sergey. That definitely helped.

In the spirit of "teaching a man to fish" :) can you tell me what the Path parameter is for and an example of when you'd use it?
 
New Post
5/7/2011 10:29 AM
 
Chad

You are welcome!

To be honest, we do not use FriendlyURL often. Usually we use NavigationURL. But sometimes we use it for registration, login, privacy or terms links. Then code looks like this:


Dim
objTabController As New DotNetNuke.Entities.Tabs.TabController()
Dim objTab As DotNetNuke.Entities.Tabs.TabInfo = objTabController.GetTab(Me.TabId)
Dim CorrectURL As String = DotNetNuke.Common.Globals.FriendlyUrl(objTab, "?ctl=login&returnurl=myurl")


This code returns URL like this:

http://site.com/login.aspx?ReturnUrl=myurl

Also you can use ctl=register or ctl=terms or ctl=privacy. On other situations we use NavigationURL.

Hope this helps!

Sergey
 
Previous
 
Next
HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesFriendlyURL Method HelpFriendlyURL Method Help


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