Page 2 of 3
Posted: Tue Oct 03, 2006 7:01 pm
by Ambush Commander
It's all about how you deal with duplicates. :-/
Posted: Tue Oct 03, 2006 7:16 pm
by s.dot
I never have duplicates. I include the ID i've pulled from a database in the URL.
forums/view-topic/12345/some-topic-title.html
Posted: Tue Oct 03, 2006 7:22 pm
by Ambush Commander
untitled or a similar variant (make it configurable) sounds reasonable to me.
Posted: Tue Oct 03, 2006 8:26 pm
by s.dot
Good call. I edited the original post to include another parameter that defaults to 'no-title'. Lots of paramter calls =/ But the function works!
Posted: Tue Oct 03, 2006 8:28 pm
by Ambush Commander
At this point I would have turned into a class...
Note that using empty() will also cause pages called "0" to be switched to blank.
Posted: Tue Oct 03, 2006 10:14 pm
by nickvd
What about just failing on a "null" input... if i enter !@#!@#*!&@#(*&!@# it's going to spit out '', but instead of blindly accepting it and turning it into something the user wont be expecting (and therefore probably just re-enter the same data), you just return to the form page with an error, "Only use a-z,0-9,etc in your title"
Posted: Wed Oct 04, 2006 1:31 am
by s.dot
Ambush Commander wrote:At this point I would have turned into a class...
Note that using empty() will also cause pages called "0" to be switched to blank.
I probably will classalize it. Good call with the empty(), I would've never caught that myself.
nickvd wrote:What about just failing on a "null" input... if i enter !@#!@#*!&@#(*&!@# it's going to spit out '', but instead of blindly accepting it and turning it into something the user wont be expecting (and therefore probably just re-enter the same data), you just return to the form page with an error, "Only use a-z,0-9,etc in your title"
That would defeat the purpose of what this does. If they put in something like that, they likely don't care about the title anyways.

Besides, their original title will still show up on the page, this is just for a URL.
Posted: Wed Oct 04, 2006 2:00 am
by s.dot
Alright, I turned it into the shortest class ever. I added a default maxlength of 50. I probably won't do too much more to it. Hopefully someone else will find it useful. ;d Thanks for the tips everyone!
Posted: Wed Oct 04, 2006 8:41 am
by n00b Saibot
scottayy wrote:Hopefully someone else will find it useful.
Have you posted it in the code snippets?
Posted: Wed Oct 04, 2006 9:07 am
by DaveTheAve
*cough*
Don't Look Here *cough*
Posted: Wed Oct 04, 2006 11:04 am
by Luke
I already suggested that... it's not what he's looking for... this is for something else.
Posted: Wed Oct 04, 2006 2:49 pm
by s.dot
A lot of you are missing the point
The point is keyword rich - human readable, urls.
For example, I recently started using this on my forums.
The world news & current events forum
- Before - showforum.php?forumid=21
- After - forums/21/world-news-and-current-events/index.php
A topic in that forum.....
- Before - showthread.php?threadid=22107
- After - forums/view-topic/22107/yet-another-school-shooting.php
That would look terrible if it were yet%20another%20school%20shooting%2E.php
Have you posted it in the code snippets?
I can't, it's a closed forum.
Posted: Wed Oct 04, 2006 2:55 pm
by Luke
yea I understand what you're trying to do now scottayy
Posted: Wed Oct 04, 2006 3:07 pm
by DaveTheAve
scottayy wrote:
- Before - showthread.php?threadid=22107
- After - forums/view-topic/22107/yet-another-school-shooting.php
That would look terrible if it were yet%20another%20school%20shooting%2E.php
Well, that was done with .htaccess.... and you could implatment the dashes with this:
Code: Select all
$url = urlencode($_GET['url']);
$url = str_replace("%20","-",$url);
note that was not tested and will most likely not work but it was just a idea to throw out there.
Posted: Thu Oct 05, 2006 1:19 am
by matthijs
Certainly a useful function/class. Some CMS systems do the same thing (like wordpress). It automaticly turns the title you choose for an article into the permalink and nice url, in a way you showed (nice-title-of-the-article).
Good work scottayy (and others), I might use the function some day.