2006-02-04, 04:58 AM
$seo_forumname = str_replace('+', '_', urlencode($forum['name']));
Urlencode replaces a space with +, and encodes other characters, to a form that will pass W3 validation.
( like & to $amp; )
$seo_forumname = str_replace('+', '_', urlencode($forum['name']));
Detruire Wrote:( like & to & )You're thinking of htmlspecialchars(), not urlencode().
Quote:As for other characters that shouldn't be in a URL, they should also just be replaced with underscores, or even removed, since the goal is to make the URLs look as nice as possible.
Detruire Wrote:Why not do something like what Devshed has done, which is slightly better looking then how this way will end up.You mean like this? (forum name, forum ID, thread name, thread ID)
WDZ Wrote:That could be a possibiliy, but for the first release I will keep it the way it is with capitals.Detruire Wrote:Why not do something like what Devshed has done, which is slightly better looking then how this way will end up.You mean like this? (forum name, forum ID, thread name, thread ID)
/php-development-5/form-validation-is-this-needed-323647.html
/php-development-5/cookie-phpsessid-is-set-but-i-can-t-find-the-323403.html
That looks pretty good... they strip down the URLs pretty aggressively... removing all capitalization and non-alphanumeric characters...
WDZ Wrote:Well, for example, this is a snippet of the HTML of your index page...Hi,
<a href="forum-5-Testing Forum.html">Testing Forum</a>
Which you want to have an underscore in it like so...
<a href="forum-5-Testing_Forum.html">Testing Forum</a>
And I assume your template currently looks like this...
<a href="forum-$forum[fid]-$forum[name].html">$forum[name]</a>
What you need is a new variable containing the forum name with all spaces replaced with underscores. You would need to add a line of PHP code like this to index.php (for this example) to create that variable...
Then use the new $seo_forumname variable in your <a href="..."> code.$seo_forumname = str_replace(" ", "_", $forum['name']);
Of course, this modification may have to be done in many places... wherever you use a forum name in one of your SEO URLs. Oh, and the thread names too. It might be possible to use the plugins system to some extent to help ease the task of making all those modifications, but I'm not sure...
$seo_forumname = str_replace(" ", "_", $forum['name']);
Quote:forum-$forum[fid]-$seo_forumname.html
Quote:http://www.mydevote.com/forum/forum-5-.html
global $fcache, $moderatorcache, $forumpermissions, $theme, $mybb, $mybbforumread, $settings, $mybbuser, $excols, $fcollapse, $templates, $bgcolor, $collapsed, $lang, $showdepth, $forumpass, $plugins;
toglobal $fcache, $moderatorcache, $forumpermissions, $theme, $mybb, $mybbforumread, $settings, $mybbuser, $excols, $fcollapse, $templates, $bgcolor, $collapsed, $lang, $showdepth, $forumpass, $plugins, $forum;
kodaks Wrote:Is there something I did wrong? Thanks!Well, how good is your PHP knowledge? I'm assuming you know where to place the new code, but just in case you don't, I'd suggest placing it right after this code in index.php, around line 236...
$plugins->run_hooks("index_forum");
If it works there, then you'll know it will work if you decide to make it a plugin in the future.