Originally Posted by SD
PHP Code
$title = preg_replace("#[^A-Za-z0-9]+#", "-", strtolower($title));
$title = preg_replace("#(-){2,}#", "$1", $title);
$title = trim($title, '-');
$title = substr($title, 0, 30);  


seems a shorter way to do it. maybe i missed something.. :shrug:

Yup, you did.

While I detailed what each line does (for the reader), most importantly, FIRSTLY replace the common space (& nbsp;) and ampersand (& amp;) markup code with dashes - which some browsers like to auto insert to coppied urls (Firefox). You might also want to check templates/default/forum.tpl, because it does the same thing to urls in the "last post" column. (Further reading regarding forum.tpl, see line 330 and below of libs/functions_forums.inc.php, regarding the comment to escape the quotes in the subject)

The code I posted/linked to, recognizes this, and fixes it.

In addition, since $title is already limited in the newtopic template to 50 characters (IIRC) -- and since long URLs are split at 40 & -15 (line 566 of libs\bbcode.inc.php), running a substr on it again may be redundant.

What might be an improvement to how UBBT handles internal urls for the forum reader and for SEO strategy, is that if a link comes from the same domain and ubbt forum, the link is displayed as human-readable-text, such as "[This Topic We Are Discussing]", rather than just a URL with an ellipsis halfway through the url // and the first part of the url's title/description. AND to go one step further, if that link is on the same domain, do not add a "NOFOLLOW" meta attribute to it. This would be added just above, in bbcode.inc.php, by making a check to the url. if it preg_match #site-domain-name-url#, then $this->nofollow = '';

As always in coding, there are a million ways something can be written to perform the same output as what some one else has coded. It's no competition to see who is right and who is wrong in the process. In the end, having the correct output should be the ultimate goal.


Current developer of UBB.threads PHP Forum Software
Current Release: UBBT 7.7.5 // Preview: UBBT 8.0.0
isaac @ id242.com // my forum @ CelicaHobby.com