Tim Maxey .NET Technology Blog & Resources

DNN SEO URL Firendly URL Dashes in Tabname

So in DotNetNuke you want the SEO friendly URL like my-web-page-is-cool.aspx correct? Well unless you want to purchase the $120 deal and learn it, go ahead, but for me I just needed the dashes, that's all, didn't want to pay $120 for a thrid party module, ya know?

So I came across this post: http://rubicite.com/Tutorials/DotNetNukeFriendlyURLSeparators.aspx which I had to modify my DNN source with C# so get the code, open it up and go to the library/commons and globals and change this function:

 public static string GenerateTabPath(int ParentId, string TabName)

 To this:

 

public static string GenerateTabPath(int ParentId, string TabName)
        {
            string strTabPath = "";
            var objTabs = new TabController();

            if (!Null.IsNull(ParentId))
            {
                string strTabName;
                var objTab = objTabs.GetTab(ParentId, Null.NullInteger, false);
                while (objTab != null)
                {
                    //strTabName = HtmlUtils.StripNonWord(objTab.TabName, false);
                    string S = System.Text.RegularExpressions.Regex.Replace(objTab.TabName, "[\\s]+", "-");
                    S = System.Text.RegularExpressions.Regex.Replace(S, "[^\\w-]*", "");
                    strTabName = S;
                    strTabPath = "//" + strTabName + strTabPath;
                    if (Null.IsNull(objTab.ParentId))
                    {
                        objTab = null;
                    }
                    else
                    {
                        objTab = objTabs.GetTab(objTab.ParentId, objTab.PortalID, false);
                    }
                }
            }

            //strTabPath = strTabPath + "//" + HtmlUtils.StripNonWord(TabName, false);
            string S2 = System.Text.RegularExpressions.Regex.Replace(TabName, "[\\s]+", "-");
            S2 = System.Text.RegularExpressions.Regex.Replace(S2, "[^\\w-]*", "");
            strTabPath = strTabPath + "//" + S2;
            return strTabPath;
        }

 

Rebuild the "Library" upload new DotNetNuke dll and you are set, work like a champ, it's getting ready to be used on http://DTGDNN.noptm.com, then on their live site: Direct to Garment Printer

 

Hope this help someone else! Let me know if you want the dll, mine id 6.1.3.108, but for if you like shoot me an email and for $40 I will take current version of DNN amd update the dll for ya if you have a different version.!


Feedback

No comments posted yet.


Post a comment





 

Please add 6 and 1 and type the answer here: