Similar Topics 1.0.1
Written by: ntd1712
Description:
- This mod adds a table at the bottom of a topic and displays other topics that are silimar in topic (title).
File to edit:
./cache/lang_cache/lang_topic.php
./sources/action_public/topic.php
---------------------------------------------------------------------------------------------
Mở: ./cache/lang_cache/lang_topic.php
Tìm:
CODE
<?php
$lang = array (
Thêm dưới:
CODE
// Similar Topics
'st_main' => "Similar Topics",
'st_title' => "Topic Title",
'st_post_on' => "This topic was started:",
'st_replies' => "Replies",
'st_starter' => "Topic Starter",
'st_views' => "Views",
'st_lastinfo' => "Last Action",
'st_by' => "Last post by:",
'st_nodata' => "No entries to display",
---------------------------------------------------------------------------------------------
Mở: ./sources/action_public/topic.php
Tìm:
CODE
//-----------------------------------------
// Process users active in this forum
//-----------------------------------------
Thêm bên trên:
CODE
//-----------------------------------------
// Similar Topics
//-----------------------------------------
$this->output = str_replace( "<!--IBF.SIMILAR_TOPICS-->", $this->similar_topics(), $this->output );
Tìm:
CODE
/*-------------------------------------------------------------------------*/
// Render the moderator links
/*-------------------------------------------------------------------------*/
THêm trên:
CODE
/*-------------------------------------------------------------------------*/
// Similar Topics
/*-------------------------------------------------------------------------*/
function similar_topics()
{
require_once( ROOT_PATH.'sources/action_public/search.php' );
$search = new search;
$search->ipsclass =& $this->ipsclass;
//-----------------------------------------
// Get forums we're allowed to read
//-----------------------------------------
$this->ipsclass->input['forums'] = 'all';
$forums = $search->get_searchable_forums();
$t_fid = ( $forums != "" ) ? "forum_id IN (".$forums.") AND " : "";
//-----------------------------------------
// Parse data
//-----------------------------------------
$boolean = "";
if( ($this->ipsclass->DB->sql_can_fulltext_boolean() == TRUE) && ($this->ipsclass->vars['search_sql_method'] == 'ftext') )
{
$boolean = ' IN BOOLEAN MODE';
$t_title = $search->filter_ftext_keywords( $this->topic['title'] );
}
else
{
$t_title = $search->filter_keywords( $this->topic['title'] );
$t_title = str_replace("%", "", $t_title);
}
$t_title = trim($t_title);
if( (! $t_title) || ($t_title == "") || (! isset($t_title)) || (strlen($t_title) < 4) )
{
return;
}
if( ($this->ipsclass->DB->sql_can_fulltext() == TRUE) && ($this->ipsclass->vars['search_sql_method'] == 'ftext') )
{
$db_where = " AND MATCH (title) AGAINST ('".$t_title."'".$boolean.")";
}
else
{
$t_str = explode(" ", $t_title);
$t_cnt = count($t_str);
for( $i = 0; $i < $t_cnt; $i++ )
{
if( (! empty($t_str[$i])) && (strlen($t_str[$i]) > 3) )
{
$words[] = "'%".$t_str[$i]."%'";
$word[] = ( $t_cnt > 1 ) ? '('.implode(' OR LOWER(title) LIKE ', $words).')' : implode(' OR LOWER(title) LIKE ', $words);
unset($words);
}
}
$sql_words .= ' '.implode(" OR LOWER(title) LIKE ", $word);
unset($word);
$db_where = ( ! empty($sql_words) ) ? " AND (LOWER(title) LIKE ".$sql_words.")" : "";
}
$this->ipsclass->DB->simple_construct( array( 'select' => '*',
'from' => 'topics',
'where' => $t_fid."tid != ".$this->topic['tid']." AND title IS NOT NULL AND approved=1".$db_where,
'order' => 'last_post DESC',
'limit' => array(0,5) ) );
$sql = $this->ipsclass->DB->simple_exec();
if( $this->ipsclass->DB->get_num_rows( $sql ) )
{
while( $r = $this->ipsclass->DB->fetch_row( $sql ) )
{
$r['start_name'] = $this->ipsclass->make_profile_link( $r['starter_name'], $r['starter_id'] );
$r['start_date'] = $this->ipsclass->get_date( $r['start_date'], 'LONG' );
$r['replies'] = $this->ipsclass->do_number_format( intval($r['posts']) );
$r['views'] = $this->ipsclass->do_number_format( intval($r['views']) );
$r['last_post'] = $this->ipsclass->get_date( $r['last_post'], 'LONG' );
$r['last_name'] = $this->ipsclass->make_profile_link( $r['last_poster_name'], $r['last_poster_id'] );
$data['st_row'] .= $this->ipsclass->compiled_templates['skin_topic']->topic_display_similar_row( $r );
}
}
else
{
$data['st_row'] .= "<tr><td class='row2' colspan='5' align='center'><i>{$this->ipsclass->lang['st_nodata']}</i></td></tr>";
}
$collapsed_ids = ','.$this->ipsclass->my_getcookie('collapseprefs').',';
$show['div_fo'] = 'show';
$show['div_fc'] = 'none';
if( strstr($collapsed_ids, ',stopics,') )
{
$show['div_fo'] = 'none';
$show['div_fc'] = 'show';
}
return $this->ipsclass->compiled_templates['skin_topic']->topic_display_similar( $show, $data );
}
Vào Admin CP: Skin & Templates: Skin Manager: Edit Root Skin Template HTML:
Vào: Topic View --> TableFooter
Tìm:
CODE
<!--IBF.TOPIC_ACTIVE-->
Thêm bên trên:
CODE
<!--IBF.SIMILAR_TOPICS-->
---------------------------------------------------------------------------------------------
Add Template Bit
- New Template Bit Name: topic_display_similar
- New Template Bit Incoming Data Variables: $show="",$data=""
- New Template Bit Group...: skin_topic
- Click 'Continue...' button. Dán đoạn code sau vào khung to:
CODE
<div class='borderwrap' style="display:{$show['div_fc']};" id='fc_stopics'>
<div class='maintitlecollapse'>
<p class='expand'><a href="javascript:togglecategory('stopics',0);"><{E_PLUS}></a></p>
<p><{CAT_IMG}> {ipb.lang['st_main']}</p>
</div>
</div>
<div class='borderwrap' style="display:{$show['div_fo']};" id='fo_stopics'>
<div class='maintitle'>
<p class='expand'><a href="javascript:togglecategory('stopics',1);"><{E_MINUS}></a></p>
<p><{CAT_IMG}> {ipb.lang['st_main']}</p>
</div>
<table class='ipbtable' cellspacing='1'>
<tr>
<th width='50%'>{ipb.lang['st_title']}</td>
<th width='7%' align='center' nowrap='nowrap'>{ipb.lang['st_replies']}</td>
<th width='14%' align='center' nowrap='nowrap'>{ipb.lang['st_starter']}</td>
<th width='7%' align='center' nowrap='nowrap'>{ipb.lang['st_views']}</td>
<th width='22%' nowrap='nowrap'>{ipb.lang['st_lastinfo']}</td>
</tr>
{$data['st_row']}
</table>
</div><br />
- Save Template Bit
---------------------------------------------------------------------------------------------
Add Template Bit
- New Template Bit Name: topic_display_similar_row
- New Template Bit Incoming Data Variables: $data=""
- New Template Bit Group...: skin_topic
- Click on 'Continue...'
Dán đoạn code sau:
CODE
<tr>
<td class='row2'><a href="{ipb.script_url}showtopic={$data['tid']}" title="{ipb.lang['st_post_on']} {$data['start_date']}">{$data['title']}</td>
<td class='row2' align='center'>{$data['replies']}</td>
<td class='row2' align='center'>{$data['start_name']}</a></td>
<td class='row2' align='center'>{$data['views']}</td>
<td class='row2'><span class='lastaction'>{$data['last_post']}<br /><a href="{ipb.script_url}showtopic={$data['tid']}&view=getlastpost">{ipb.lang['st_by']}</a> {$data['last_name']}</a></span></td>
</tr>
- Save Template Bit
©2005 ntd1712