I have a small problem, hopefully you can give me some insight on this matter. I am integrating my website with the phpbb forum. I have the latest advanced seo mod installed on my forum, as well as the other seo toolkit mods. On my news page I fetch posts from the database and display them. A few of the URLs are rewritten but some of them are not and I am hoping you can help me with this. Below is a portion of my news script which fetches posts from the forum for display. Perhaps I am just missing an included file? My post-author/member links are rewritten, as well as the forum url but the viewtopic.php?t=1 etc. links are not rewritten, and I would like them to be rewritten to the topic url such as mysite.com/this-topic/. Thank you for your help.
- Code: Select all
<?php
define('IN_PHPBB', true);
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data);
//news script variables
$charlimit = '0';
$timestamp = 'D M j, Y g:i a';
$forum_id = array('2');
$showavatars = 'false';
$newsdisplay = '10';
$allow_bbcode = true;
$allow_smilies = false;
$allow_urls = true;
// Auth
$can_read_forum = $auth->acl_getf('f_read'); //Get the forums the user can read from
$forums_auth_ary = array_keys($can_read_forum); //Re-work the array some
$authed_news_ary = array_intersect($forum_id, $forums_auth_ary); //Of the desired forums, pull out the authed ones
unset($can_read_forum);
unset($forums_auth_ary);
$sql = 'SELECT t.forum_id, t.topic_id, t.topic_title, t.topic_replies, p.post_id, p.post_subject, p.post_text, p.post_time, p.bbcode_bitfield, p.bbcode_uid, u.username, u.user_id, u.user_avatar, u.user_avatar_type, u.user_avatar_width, u.user_avatar_height, u.user_colour
FROM ' . TOPICS_TABLE . ' t
INNER JOIN ' . POSTS_TABLE . ' p ON (t.topic_id = p.topic_id)
INNER JOIN ' . USERS_TABLE . ' u ON (p.poster_id = u.user_id)
WHERE t.topic_approved = 1
AND p.post_approved = 1
AND ' . $db->sql_in_set('p.forum_id', $authed_news_ary) . '
AND p.post_id = t.topic_first_post_id
ORDER BY p.post_time DESC';
$result = $db->sql_query_limit($sql, $newsdisplay);
$row = $db->sql_fetchrowset($result);
$db->sql_freeresult($result);
$flags = (($allow_bbcode) ? OPTION_FLAG_BBCODE : 0) + (($allow_smilies) ? OPTION_FLAG_SMILIES : 0) + (($allow_urls) ? OPTION_FLAG_LINKS : 0);
// Check that we have enough entries to display
if(sizeof($row) < $newsdisplay)
{
$newsdisplay = sizeof($row);
}
//
// Organize the posts into an array
// Trim and work some display magic if necessary
//
$posts = array();
for($i = 0; $i < $newsdisplay; $i++)
{
$posts[$i]['topic_id'] = $row[$i]['topic_id'];
$posts[$i]['forum_id'] = $row[$i]['forum_id'];
$posts[$i]['topic_replies'] = $row[$i]['topic_replies'];
$posts[$i]['post_time'] = date($timestamp, $row[$i]['post_time']);
$posts[$i]['topic_title'] = $row[$i]['topic_title'];
$posts[$i]['post_subject'] = $row[$i]['post_subject'];
$posts[$i]['user_id'] = $row[$i]['user_id'];
$posts[$i]['user_link'] = get_username_string('full', $row[$i]['user_id'], $row[$i]['username'], $row[$i]['user_colour']);
$posts[$i]['user_avatar'] = get_user_avatar($row[$i]['user_avatar'], $row[$i]['user_avatar_type'], $row[$i]['user_avatar_width'], $row[$i]['user_avatar_height']);
$posts[$i]['topic_link'] = append_sid("{$forum_root_path}viewtopic.$phpEx", 'f=' . $posts[$i]['forum_id'] . '&t=' . $posts[$i]['topic_id']);
$posts[$i]['reply_link'] = append_sid("{$forum_root_path}posting.$phpEx", 'mode=reply&f=' . $posts[$i]['forum_id'] . '&t=' . $posts[$i]['topic_id']);
censor_text($posts[$i]['topic_title']);
censor_text($posts[$i]['post_subject']);
$post_text = '';
//If the text is short enough, don't trim it, and fully display it with BBCdoes, Smilies, and URLs
if(($charlimit == 0) || (strlen($row[$i]['post_text'] <= $charlimit)))
{
$posts[$i]['message'] = generate_text_for_display($row[$i]['post_text'], $row[$i]['bbcode_uid'], $row[$i]['bbcode_bitfield'], $flags);
}
else
{
strip_bbcode($row[$i]['post_text']);
censor_text($row[$i]['post_text']);
$posts[$i]['message'] = substr($row[$i]['post_text'], 0, $charlimit) . '...' . '<br /><br /><a href="' . $posts[$i]['topic_link'] . '">[Read More]</a>';
}
$sql = 'SELECT forum_name
FROM ' . FORUMS_TABLE . '
WHERE forum_id = ' . intval($posts[$i]['forum_id']);
$result = $db->sql_query($sql);
$posts[$i]['forum_name'] = $db->sql_fetchfield('forum_name');
$db->sql_freeresult($result);
if($posts[$i]['topic_title'] == '')
{
continue;
}
$template->assign_block_vars('fetchpost_row', array(
'AVATAR' => $posts[$i]['user_avatar'],
'FORUM_NAME' => $posts[$i]['forum_name'],
'POSTER' => $posts[$i]['user_link'],
'POST_SUBJECT' => $posts[$i]['post_subject'],
'POST_TIME' => $posts[$i]['post_time'],
'REPLIES' => $posts[$i]['topic_replies'],
'TEXT' => $posts[$i]['message'],
'TOPIC_TITLE' => $posts[$i]['topic_title'],
'U_FORUMLINK' => append_sid("{$forum_root_path}viewforum.$phpEx", 'f=' . $posts[$i]['forum_id']),
'U_REPLYLINK' => $posts[$i]['reply_link'],
'U_VIEWLINK' => $posts[$i]['topic_link'],
));
}
$template->set_filenames(array(
'body' => 'home.html',
));
page_footer();
?>

English |
French
News
phpBB SEO
