2008-12-21, 03:13 PM
I'm currently in the middle of developing a SEO plugin for MyBB, called Google SEO plugin. The goal of this plugin is to implement the guidelines of the recently released Google's SEO starter guide.
Regarding the implementation of custom SEO URLs, I found that MyBB has a very nice API for creating links to the most important pages, in inc/functions.php:
Naturally in order to implement custom SEO urls, my plugin hooks into these functions to gain support for SEO urls in all MyBB and even in third party plugins. Or so I thought. It only works when this API is actually used.
So far I found that MyBB itself uses its own API basically everywhere, except in two places that involve multipage().
In forumdisplay.php it's this part:
In showthread.php it's this part:
It would help me very much if the get_forum_link() / get_thread_link() functions were used instead of FORUM_URL_PAGED / THREAD_URL_PAGED in these two locations.
Change proposal for forumdisplay.php:
Change proposal for showthread.php:
I'm aware that this is only a hack (page is supposed to be a number and not "{page}" when passed to get_*_link()). This is probably bad style and it prevents a third party SEO to do something interesting like replace page numbers with number words (thread-one-page-one and no I'm not doing that). For a better solution multipage() itself would have to be made aware of the get_*_link() API and call it once for every page link it produces, which may be both more complicated and expensive.
Thanks for your attention.
Regarding the implementation of custom SEO URLs, I found that MyBB has a very nice API for creating links to the most important pages, in inc/functions.php:
function get_forum_link($fid, $page=0)
function get_thread_link($tid, $page=0, $action='')
function get_post_link($pid, $tid=0)
/* ...and so on and so forth... */
Naturally in order to implement custom SEO urls, my plugin hooks into these functions to gain support for SEO urls in all MyBB and even in third party plugins. Or so I thought. It only works when this API is actually used.
So far I found that MyBB itself uses its own API basically everywhere, except in two places that involve multipage().
In forumdisplay.php it's this part:
// Assemble page URL
if($mybb->input['sortby'] || $mybb->input['order'] || $mybb->input['datecut']) // Ugly URL
{
$page_url = str_replace("{fid}", $fid, FORUM_URL_PAGED);
if($mybb->settings['seourls'] == "yes" || ($mybb->settings['seourls'] == "auto" && $_SERVER['SEO_SUPPORT'] == 1))
{
$q = "?";
$and = '';
}
else
{
$q = '';
$and = "&";
}
if($sortby != "lastpost")
{
$page_url .= "{$q}{$and}sortby={$sortby}";
$q = '';
$and = "&";
}
if($sortordernow != "desc")
{
$page_url .= "{$q}{$and}order={$sortordernow}";
$q = '';
$and = "&";
}
if($datecut > 0 && $datecut != 9999)
{
$page_url .= "{$q}{$and}datecut={$datecut}";
}
}
else
{
$page_url = str_replace("{fid}", $fid, FORUM_URL_PAGED);
}
$multipage = multipage($threadcount, $perpage, $page, $page_url);
In showthread.php it's this part:
// Work out if we have terms to highlight
$highlight = "";
if($mybb->input['highlight'])
{
if($mybb->settings['seourls'] == "yes" || ($mybb->settings['seourls'] == "auto" && $_SERVER['SEO_SUPPORT'] == 1))
{
$highlight = "?highlight=".urlencode($mybb->input['highlight']);
}
else
{
$highlight = "&highlight=".urlencode($mybb->input['highlight']);
}
}
$multipage = multipage($postcount, $perpage, $page, str_replace("{tid}", $tid, THREAD_URL_PAGED.$highlight));
It would help me very much if the get_forum_link() / get_thread_link() functions were used instead of FORUM_URL_PAGED / THREAD_URL_PAGED in these two locations.
Change proposal for forumdisplay.php:
// Assemble page URL
$page_url = get_forum_link($fid, "{page}");
if($mybb->input['sortby'] || $mybb->input['order'] || $mybb->input['datecut']) // Ugly URL
{
if(!strstr($page_url, "?"))
{
$q = "?";
$and = '';
}
else
{
$q = '';
$and = "&";
}
if($sortby != "lastpost")
{
$page_url .= "{$q}{$and}sortby={$sortby}";
$q = '';
$and = "&";
}
if($sortordernow != "desc")
{
$page_url .= "{$q}{$and}order={$sortordernow}";
$q = '';
$and = "&";
}
if($datecut > 0 && $datecut != 9999)
{
$page_url .= "{$q}{$and}datecut={$datecut}";
}
}
$multipage = multipage($threadcount, $perpage, $page, $page_url);
Change proposal for showthread.php:
// Work out if we have terms to highlight
$page_url = get_thread_link($tid, "{page}");
if($mybb->input['highlight'])
{
if(!strstr($page_url, "?"))
{
$page_url .= "?highlight=".urlencode($mybb->input['highlight']);
}
else
{
$page_url .= "&highlight=".urlencode($mybb->input['highlight']);
}
}
$multipage = multipage($postcount, $perpage, $page, $page_url);
I'm aware that this is only a hack (page is supposed to be a number and not "{page}" when passed to get_*_link()). This is probably bad style and it prevents a third party SEO to do something interesting like replace page numbers with number words (thread-one-page-one and no I'm not doing that). For a better solution multipage() itself would have to be made aware of the get_*_link() API and call it once for every page link it produces, which may be both more complicated and expensive.
Thanks for your attention.