Register Login
   
 Latest Posts  
RE: Where to edit Rating & Comments Border
by stephaniewwp on 7/24/2008 9:12 PM
RE: Where to edit Rating & Comments Border
by aviavia on 7/24/2008 8:11 PM
RE: Where to edit Rating & Comments Border
by aviavia on 7/24/2008 8:03 PM
Where to edit Rating & Comments Border
by stephaniewwp on 7/24/2008 6:52 PM
Image issue in template
by leiner on 7/24/2008 4:16 PM
RE: How to customize an existing module?
by nmduc073 on 7/24/2008 3:03 PM
RE: Few General Questions
by copemoney on 7/24/2008 2:37 PM
Germanera.com - News Articles and Simple Gallery
by akrion on 7/24/2008 2:36 PM
RE: Sites using News Articles
by akrion on 7/24/2008 2:30 PM
RE: FeedBack Center Search not working with closed cases
by BlackWarlock on 7/24/2008 2:13 PM
 Forums  
Subject: Once again with the Hyphens
Prev Next
You are not authorized to post a reply.

Page 1 of 3123 > >>
AuthorMessages
RabidmaxUser is Offline
Registered Users
Nuke Active Member
Nuke Active Member
Posts:34

5/21/2007 9:27 PM  

Ok, so like almost everyone else out there, I was hoping for page aliases to be generated with hyphens, so I did a little digging.

The function which generates the tabpath is in Globals.vb, named GenerateTabPath. It calls through to HtmlUtils.StripNonWord, which removes non-word characters and removes them (although the function has the option of replacing with a space).

StripNonWord uses a regular expression "\W*" (match any non-word character, ie anything that is not [a-zA-Z_0-9]), which as you can see will happily rip out the -s.

So I look at this function thinking 'what do we really want in the tab path?'.

Maybe we should start with some examples:

'Health & Safety' would be great as 'Health-Safety'

'What's going on?' might be nice as 'Whats-going-on'

What does that mean, how can we get this in this StripNonWord function?

1. Strip out everything that is [^\w\-\s], replace with nothing. This would remove anything that is not "a-zA-Z_0-9(hyphen)(space)" (and give us 'Health  Safety' and 'Whats going on')

2. Replace runs of spaces (\s*) with a hyphen (leaving us 'Health-Safety' and 'Whats-going-on')

3. Profit.

So that would make the line of code:

[code]

                 Return System.Text.RegularExpressions.Regex.Replace(HTML, "\W*", RepString)

[/code]

into:

[code]

                Dim Stripped As String

           
               
                Stripped = System.Text.RegularExpressions.Regex.Replace(HTML, "[^\w\-\s]", "")

                Stripped = System.Text.RegularExpressions.Regex.Replace(Stripped, "\s+", "-")

           

                Return Stripped

[/code]

I've done a search over all the DNN source code (4.4.1) and found just two places that this function is called from. One is in the GenerateTabPath function, the other is in the GenerateTabPath function also.

Well, I'm not sure if this will work, or if it's exactly what everyone has been after, or whether we can petition to get it in the proper DNN tabpath code if it is something worth doing, just thought I'd throw it out there for anyone interested. I haven't done binaries for download or anything, I'll leave that to someone else who has more time :)

Hope that helps, and is useful to someone.

Max

Robert GarciaUser is Offline
Registered Users
Nuke Active Member
Nuke Active Member
Posts:31


5/22/2007 10:15 AM  
If I could only tell you how important I think this is to the evolution of the DNN friendly url. If this one feature can be attained, then DNN would certainly take center stage in the CMS world, and we would all profit from better SERP's.

Patio Umbrellas
Dax DavisUser is Offline
Gold Membership
Nuke Master
Nuke Master
Posts:203


5/22/2007 6:28 PM  
This is great.  Thanks for looking into this.  I would suggest you go to DNN's support site and enter a ticket for this.  That's the best way to get it on the schedule.

http://support.dotnetnuke.com/project/Project.aspx?PROJID=23
RabidmaxUser is Offline
Registered Users
Nuke Active Member
Nuke Active Member
Posts:34

5/22/2007 10:29 PM  
Well, not sure if anyone is still after a hyphen solution, but I have something that someone who is might be after.

I don't have anywhere to host files at the moment, can someone PM me with somewhere I might post a module for people to link? Or PM me with your email address if you could host it for me (or just want to try it), and I'll throw it to you.

Basic description: Does everything I said above for the portal that you're currently looking at, at the click of a button (and optionally a checkbox). It's just one ascx, one .cs, and a dnn in a zip really. Uses the core DNN functions for tab management for the updates.

Seems to work quite well for me on my site, which is still in development, so no live links to show off.

Oh, it might be DNN 4.5+ specific, I don't have access to anything older anymore, and not sure when some of these functions were added (GetTabsByPortal seems relatively new...). Shouldn't be hard to devolve it though, that's about the only thing that I saw that might be controvertial, shrug.

Let me know if anyone is interested.

Max

PS, I'm in New Zealand, so you'll need to wait till about 8am NZ time till you have a chance of hearing back from me, it's not because I'm ignoring you, honest.
Déclic VidéoUser is Offline
Gold Membership
Nuke Master
Nuke Master
Posts:504


5/29/2007 7:41 AM  
Anybody tried this module ??
On my part, I can not take the risk to test a module on a prod site (I had too many problems in the past with little module and testing...).


DV

Non linear video editing software, tips and tricks, tutorials... Déclic Vidéo FX
Bruce OnderUser is Offline
Registered Users
Nuke Newbie
Nuke Newbie
Posts:7

5/29/2007 9:43 PM  

I can test it.  I can also host it for a time if it works.  Please send me a private message.

--Bruce

Bruce OnderUser is Offline
Registered Users
Nuke Newbie
Nuke Newbie
Posts:7

5/30/2007 12:21 AM  
It works great. I stuck it in a document library on my new site (so new it has no content, really, other than this library!).

You can get it here:

http://www.insure-a-pet.com/Resources/DNN-Stuff.aspx
RabidmaxUser is Offline
Registered Users
Nuke Active Member
Nuke Active Member
Posts:34

5/30/2007 3:48 AM  
Hi Bruce, glad you liked the module. I'll work on a couple of improvements/enhancements and try to get another version to you, like we talked about briefly: Checkbox to lowercase all the tabpaths, A bit of a nicer interface and simple docs :)

They will be extremely minor to do. Tomorrow. Thanks again for giving it a bash and letting me know wht you thought of it!

For everyone else, the link posted there is currently not functional, you need to remove the hyphen to get to the correct page (http://www.insure-a-pet.com/Resources/DNNStuff.aspx). And no, the irony does not escape me ;)

Bruce gave it a run through on a DNN 4.4.0 site, so we know it works on 4.4+ atm. It won't work on DNN 3, it uses Generics which were introduced in .Net 2.0, and I'm not sure how far back in the 4.x released the procedure I am using to get the tabs was introduced.

Cheers all,
Max
Déclic VidéoUser is Offline
Gold Membership
Nuke Master
Nuke Master
Posts:504


5/30/2007 6:21 AM  
Posted By Take1 on 5/30/2007 3:48 AM

{...}
For everyone else, the link posted there is currently not functional, you need to remove the hyphen to get to the correct page (http://www.insure-a-pet.com/Resources/DNNStuff.aspx). And no, the irony does not escape me ;)
{...}

Huh... Is there any problem with the module ??? Why is the hyphen removed ?????
 
DV FX
PS: could you also explain more in detail the following:
Click the button to process all of the tab URLs into the cache. Check the box if you also want to write the URLs to the db."
What do you mean by "writing the URLs" to the db ???

Non linear video editing software, tips and tricks, tutorials... Déclic Vidéo FX
RabidmaxUser is Offline
Registered Users
Nuke Active Member
Nuke Active Member
Posts:34

5/30/2007 12:01 PM  
Hi DV,

Funnily enough both your questions are related.

The reason that the hyphen was removed was that Bruce hadn't updated the tabpaths to the database. Maybe I should explain the module a bit more.

This module has a checkbox along the lines of 'Commit to DB', and a button to start the processing.

DNN 4.5 (maybe earlier) caches all the TabInfo records, so that it doesn't have to constantly hit the database when the structure really won't change. When you change a Tab, the cache is rebuilt, that kind of thing.

When you first execute the module, with the commit button unchecked, it will create new TabPaths for all the Tabs in the current portal, and these will immediately be reflected in the global Cache for those records. So a page: Home > "What's going on?" has an original tabpath of //Home//Whatsgoingon, and this will become //Home//Whats-going-on.. but only in the cache.

This means that immediately you can start clicking around your site and see Scotts module using /Home/Whats-going-on.aspx everywhere for that URL.

However, at the point when the Application recycles, or a page is changed, the Tab cache is refreshed, and the old, 'non hyphenated' tabpaths are restored into memory and DNN starts serving those up once again.

So then we can check the commit box, and hit the execute button. The exact same thing as above happens, but this time the TabPaths are also persisted to the database. This means whenever DNN goes back to the DB to pick up the TabInfo records, it will be pulling up our hyphen-based TabPaths. So = Success!

This will work for all the tabs on the portal that the module is dropped onto, including the Admin menu for that portal. However, it does not modify the Host menu unfortunately, as that has a different PortalId, and I didn't think it was necessary to put effort into working around the problem since it would never be served publicly.

The next version I will ask Bruce to host will have another checkbox to make the TabPath all lower case, a very minor change, but one that I think should make the URLs even more friendly.

I hope that explains everything a bit more. Please let me know if I haven't and I'll try again :)

Cheers,
Max
xcentricUser is Offline
Registered Users
Nuke Active Member
Nuke Active Member
Posts:30

5/30/2007 3:04 PM  

Hey Max,

Nice work! I'm running 4.5.1 here and no problems with the mod. Now I dont have to maually edit my tabs table to get hyphens but still for lowercase. I was looking into your code and wanted to mention something. I'm not an expert in cs or regex but here goes. To get the lowercase, you could process the stripped path before adding the hyphens by using "\L" somehow. Thats regex for lowercase right? I've made some mods to your code but they are not working. My 2 cents.

RabidmaxUser is Offline
Registered Users
Nuke Active Member
Nuke Active Member
Posts:34

5/30/2007 3:14 PM  
Hi XC,

Glad that the module helps :)

As for the lowercase, I think your regex option might be for removing the lowercase letters. If you'd like to edit the source, the change is to the line:
ti.TabPath = tabpath;

to
ti.TabPath = tabpath.ToLower();


Nice and straight forward, heh.

I'll wrap it in a nice checkbox option on the interface for the next minor release though, giving users flexibility and all :)

Cheers,
Max
xcentricUser is Offline
Registered Users
Nuke Active Member
Nuke Active Member
Posts:30

5/30/2007 3:23 PM  
Instant gratificatiuon. I love it! You da man! Your work is appreciated. Now all that has to be done is to automate it.
RabidmaxUser is Offline
Registered Users
Nuke Active Member
Nuke Active Member
Posts:34

5/30/2007 3:39 PM  
Excellent, happy to help :)

I've been thinking about automation too, bonder mentioned to me in an email that it could fit nicely as a schedulable object thing (I think that's the technical term), and I've done a quick investigation and it shouldn't be impossible.

The question I come back to is 'how often should this need to be run?'. I mean a scheduled task could run quite often, and once the site is stable and the structure changing very infrequently, it would be doing quite a lot of work (on a large site) that is unnecessary... there is also the problem (maybe?) of the links being incorrect for a (possbily long period of) time, between the tab settings update/creation and the task running.

We'll have to see, maybe ppl here can discuss and decide if it's really needed before I go ahead and invest time into it :)

Cheers,
Max
xcentricUser is Offline
Registered Users
Nuke Active Member
Nuke Active Member
Posts:30

5/30/2007 6:02 PM  
I see. I think scheduling would simulate automation but would it be a better goal to attack the source to incorporate rather than circumvent? The links need to be live after a page update. A delay of even a couple of minutes could discourage a visitor with 404's. Trigger your code after an insert update and delete query to the tabs table? I'm just throwing stuff out there.
RabidmaxUser is Offline
Registered Users
Nuke Active Member
Nuke Active Member
Posts:34

5/30/2007 7:25 PM  
Well, I considered making a trigger on the database table, but I didn't like that approach. Different database servers for one thing, and I didn't like 'sneaking around' behind the TabControllers back. It would also mean that tabcache would be wrong until it was refreshed from the database, and that could take a lot longer than updating the page, and going to this module and clicking 'Do It', tbh.

The only place that could possibly be the perfect location is in the DNN source code in the exact place I mentioned in the first post of this thread... I *could* modify the source, rebuild the DNN (core?) dll, and let people have that. I will not do that though, because a) it'll need a new version for every DNN binary release, and b) I don't want to sneak around behind DNN core team's back, and c) probably legal reasons I cba dealing with...

So the options remaining as I see it all involve using the TabController to rebuild the TabPaths, thus keeping the cache and database correct, the code in the current module is pretty stand alone, it should be easy to rip out and put anywhere. Maybe into a scheduled object, maybe into a module where the code is executed in Page_Load (thus everytime that page is refreshed the tabpaths would be rebuilt..), something in the skin perhaps.

I don't know where would be the best to use it, tbh. The module I thought was the best of a bad list of options, and the most flexible. And, it was the quickest to implement :P

Unless it get's in the core, anything we do is to circumvent the code that is currently there. I still haven't put anything into the DNN bug tracking software, because I couldn't see how immediately and didn't want to spend the time figuring out how to go about submitting something. Someone should probably do it though, at some point.

Shrug,
Max
Déclic VidéoUser is Offline
Gold Membership
Nuke Master
Nuke Master
Posts:504


5/31/2007 1:46 AM  
Ok, just perfect, I love your explanation ! Very clear.
Now, to be certain that I can run it without fear, can someone tell me if it is "heavy" from a server point of view, does it consume server resources or not (when running the module).

For me, my opinion: no need to schedule it, since you will never be able to be sure that it is updated when you modify a page. Otherwise, to trigger it when a setting is modified in a page, this way it is interesting.

DV FX

Non linear video editing software, tips and tricks, tutorials... Déclic Vidéo FX
RabidmaxUser is Offline
Registered Users
Nuke Active Member
Nuke Active Member
Posts:34

5/31/2007 4:56 AM  
Hi DV, good to hear my explanation was clear, I can sometimes over-explain things I think.

Hmm, is it 'heavy'? No, I really don't think so. It might take a fraction longer with a page structure with many many levels, due to having to fight DNN to keep the hyphens, but on a website with just a couple of levels it will be hardly noticable.

Btw DV, I took a look at your sitemap: http://declic-video-fx.com/sitemap.aspx, it would only do 10 updates there I believe. Something is going weird with your other sitemap though: http://www.declic-video-fx.com/sitemap.aspx (note the added www)... See the duplicated http://declic... in the URLs? Must be a glitch in the DNN sitemap code. Odd, just thought I'd let you know about it.

Good looking site there though :)

Yikes, midnight already. Time for me to get some Zzzs.

Hope that helps,
Max
Déclic VidéoUser is Offline
Gold Membership
Nuke Master
Nuke Master
Posts:504


5/31/2007 6:02 AM  
Posted By Take1 on 5/31/2007 4:56 AM
{...}Something is going weird with your other sitemap though: http://www.declic-video-fx.com/sitemap.aspx (note the added www)... See the duplicated http://declic... in the URLs? Must be a glitch in the DNN sitemap code.{...}


 

Yes, you are right, probably a bug in DNN, good job !!

DV


Non linear video editing software, tips and tricks, tutorials... Déclic Vidéo FX
xcentricUser is Offline
Registered Users
Nuke Active Member
Nuke Active Member
Posts:30

5/31/2007 2:45 PM  

I am not happy to report that there are some general exceptions being generated using this module. 2 to be exact. I performed a file and database backup before installing this mod. I noticed after installing this mod with the little lowercase tweak in the code that when you recycle the application the following general exceptions occur. After restoring the filesystem and database the errors are not generated.

AssemblyVersion: -1
PortalID: -1
PortalName:
UserID: -1
UserName:
ActiveTabID: -1
ActiveTabName:
RawURL:
AbsoluteURL:
AbsoluteURLReferrer:
UserAgent:
DefaultDataProvider:
ExceptionGUID:
InnerException: Could not load type ''.
FileName:
FileLineNumber: -1
FileColumnNumber: -1
Method:
StackTrace:
Message: System.Web.HttpException: Could not load type ''. ---> System.ArgumentException: String cannot have zero length.at System.Reflection.Assembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase)at System.Web.Compilation.BuildManager.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase)--- End of inner exception stack trace ---at System.Web.Compilation.BuildManager.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase)at DotNetNuke.Framework.Reflection.CreateType(String TypeName, String CacheKey, Boolean UseCache, Boolean IgnoreErrors)
Source:
Server Name: SERVER02

 


AssemblyVersion: -1
PortalID: -1
PortalName:
UserID: -1
UserName:
ActiveTabID: -1
ActiveTabName:
RawURL:
AbsoluteURL:
AbsoluteURLReferrer:
UserAgent:
DefaultDataProvider:
ExceptionGUID:
InnerException: Value cannot be null. Parameter name: type
FileName:
FileLineNumber: -1
FileColumnNumber: -1
Method:
StackTrace:
Message: System.ArgumentNullException: Value cannot be null. Parameter name: typeat System.Activator.CreateInstance(Type type, Boolean nonPublic)at DotNetNuke.Framework.Reflection.CreateObject(String TypeName, String CacheKey)at DotNetNuke.Services.Search.ModuleIndexer.GetModuleList(Int32 PortalID)
Source:
Server Name: SERVER02

You are not authorized to post a reply.
Page 1 of 3123 > >>

Forums > Projects > Friendly Urls > Once again with the Hyphens



ActiveForums 3.7