WordPress and similar topics in phpbb
-
Hi,
In phpbb, there is a nice mod : [url=http://www.phpbb.com/community/viewtopic.php?f=69&t=1659425]Similar Topics[/url], this mod show similars topics by title in the bottom of the page.
What i need is to use this mod to do the same with the wordpress article : show in the bottom of the article topics similars to the title of my article.
So i add this on single.php wp template :
<?php define('IN_PHPBB', TRUE); $phpbb_root_path = 'forum/'; $phpEx = substr(strrchr(__FILE__, '.'), 1); include($phpbb_root_path . 'common.' . $phpEx); // Start session management $user->session_begin(); $auth->acl($user->data); $user->setup('', $forum_data['forum_style']); ?> <?php $topic_data['topic_title']="dechirure"; // Begin similar topics $sql_array = array( 'SELECT' => 'f.forum_id, f.forum_name, t.topic_id, t.topic_title, u.user_id, u.username, u.user_colour, t.topic_replies', 'FROM' => array( TOPICS_TABLE => 't', ), 'LEFT_JOIN' => array( array( 'FROM' => array(USERS_TABLE => 'u'), 'ON' => 'u.user_id = t.topic_poster' ), array( 'FROM' => array(FORUMS_TABLE => 'f'), 'ON' => 'f.forum_id = t.forum_id' ), ), 'WHERE' => "MATCH (t.topic_title) AGAINST ('" . $db->sql_escape($topic_data['topic_title']) . "' ) >= 0.5 AND t.topic_status <> " . ITEM_MOVED . ' AND t.topic_id <> ' . (int) $topic_data['topic_id'], 'GROUP_BY' => 't.topic_id', 'ORDER_BY' => 't.topic_last_post_time DESC', ); $sql = $db->sql_build_query('SELECT', $sql_array); if ($result = $db->sql_query_limit($sql, 5)) { while($similar = $db->sql_fetchrow($result)) { if ($auth->acl_get('f_read', $similar['forum_id'])) { $similar_forum_url = append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=" . $similar['forum_id']); $similar_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=" . $similar['forum_id'] . '&t=' . $similar['topic_id']); $similar_user = get_username_string('full', $similar['user_id'], $similar['username'], $similar['user_colour'], $similar['username']); $template->assign_block_vars('similar', array( 'TOPIC_TITLE' => $similar['topic_title'], 'U_TOPIC' => $similar_topic_url, 'REPLIES' => $similar['topic_replies'], 'USER' => $similar_user, 'U_FORUM' => $similar_forum_url, 'FORUM' => $similar['forum_name']) ); $titre=$similar['topic_title']; $url=$similar_topic_url; echo "<a href=\"$url\" title=\"$titre\">$titre</a><br />"; } } } // End Similar Topics ?>It work fine : this display a list of phpbb topics that have on the title the keyword “dechirure”
Next : need to replace “dechirure” by the variable of wordpress title, but do not work for me 😳
need your help here please 😐
The topic ‘WordPress and similar topics in phpbb’ is closed to new replies.