It is a few more technical than the first part, but you have learned the hardest.
For that second part of the tutorial, I am going to use Precise Similar Topics II as example.
When it is installed, if you had already applied attributes to topics, you'll see no attributes in the table.
Even if you have adapted like in the first part, you will not see attributes on your topics titles.
Why ? Because the table of the topics is not entirely loaded from the database.
So, we will need to add a small part of code.
If you look good in the includes/functions_similar_topics.php file, you will see the database query :
Code: Select all
$sql_array = array(
'SELECT' => 'f.forum_id, f.forum_name,
t.topic_id, t.topic_title, t.topic_time, t.topic_views, t.topic_replies, t.topic_poster, t.topic_first_poster_name, t.topic_first_poster_colour,
MATCH (t.topic_title) AGAINST (\'' . $db->sql_escape($topic_title) . '\') as score',
'FROM' => array(
TOPICS_TABLE => 't',
),
'LEFT_JOIN' => array(
array(
'FROM' => array(FORUMS_TABLE => 'f'),
'ON' => 'f.forum_id = t.forum_id'
)
),
'WHERE' => "MATCH (t.topic_title) AGAINST ('" . $db->sql_escape($topic_title) . "') >= 0.5
AND t.topic_status <> " . ITEM_MOVED . '
AND t.topic_time > (UNIX_TIMESTAMP() - ' . $config['similar_topics_time'] . ')
AND t.topic_id <> ' . (int) $topic_data['topic_id'],
// 'GROUP_BY' => 't.topic_id',
// 'ORDER_BY' => 'score DESC',
);
Here we need to add the additional columns of the MOD (
topic_attr_id
, topic_attr_user
and topic_attr_time
).If you want to add them simple, search :
Code: Select all
, t.topic_title
And in-line, add after :
Code: Select all
, t.topic_attr_id, t.topic_attr_user, t.topic_attr_time
Save your file, upload it to its proper location and refresh the page.
Your attributes will now be displayed.
Having said that, as I like technical, there is another solution .
If you look carefully the code, you can see the query uses the
$sql_array
variable as name. And all the loaded data are in the SELECT
key.If you want to do something clean, you can add that after the array :
Code: Select all
//-- mod : quick title edition -------------------------------------------------
//-- add
$sql_array['SELECT'] .= array(', t.topic_attr_id, t.topic_attr_user, t.topic_attr_time');
//-- fin mod : quick title edition ---------------------------------------------
So, you should obtain something like this :
Code: Select all
$sql_array = array(
'SELECT' => 'f.forum_id, f.forum_name,
t.topic_id, t.topic_title, t.topic_time, t.topic_views, t.topic_replies, t.topic_poster, t.topic_first_poster_name, t.topic_first_poster_colour,
MATCH (t.topic_title) AGAINST (\'' . $db->sql_escape($topic_title) . '\') as score',
'FROM' => array(
TOPICS_TABLE => 't',
),
'LEFT_JOIN' => array(
array(
'FROM' => array(FORUMS_TABLE => 'f'),
'ON' => 'f.forum_id = t.forum_id'
)
),
'WHERE' => "MATCH (t.topic_title) AGAINST ('" . $db->sql_escape($topic_title) . "') >= 0.5
AND t.topic_status <> " . ITEM_MOVED . '
AND t.topic_time > (UNIX_TIMESTAMP() - ' . $config['similar_topics_time'] . ')
AND t.topic_id <> ' . (int) $topic_data['topic_id'],
// 'GROUP_BY' => 't.topic_id',
// 'ORDER_BY' => 'score DESC',
);
//-- mod : quick title edition -------------------------------------------------
//-- add
$sql_array['SELECT'] .= array(', t.topic_attr_id, t.topic_attr_user, t.topic_attr_time');
//-- fin mod : quick title edition ---------------------------------------------
Save your modification and upload your file to its proper location.
Refresh the page, and ... That works now .