Похожие темы

Похожие темы 1.1.0

Нет прав для скачивания

Dr_Brown

Пользователь
в топик пхп в конец, перед принт тпл

PHP:
// Похожие темы НАЧАЛО
if ($t_data['allow_reg_tracker'])
{
      $title = (strlen($topic_title) > 10) ? (substr($topic_title, 0, 10) . '') : $topic_title;
      $sgl_search = "t.topic_title LIKE '%" . addslashes($title) . "%'";

      $sql = "SELECT t.*, u.user_id, u.username, f.forum_id, f.forum_name, tor.size
            FROM ". BB_TOPICS ." t, ". BB_USERS ." u, ". BB_FORUMS ." f, ". BB_BT_TORRENTS ." tor
          WHERE t.topic_id != $topic_id
          AND tor.topic_id = t.topic_id
            AND $sgl_search
            AND f.allow_reg_tracker = 1
            AND t.forum_id = f.forum_id
            AND t.topic_poster = u.user_id
            GROUP BY t.topic_title LIMIT 0,8";
      if ( !($result = DB()->sql_query($sql)) )
      {
          bb_die("Could not get main information for similar topics");
      }
      $similar = array();
      while ( $row = DB()->sql_fetchrow($result) )
      {
          $similar[] = $row;
      }
      $count_similar = count($similar);
      if ( $count_similar > 0)
      {
          $template->assign_block_vars('similar', array());

            if ($count_similar > 2)
            {
              $page_cfg['use_tablesorter'] = true;
            }
          for($i = 0; $i < $count_similar; $i++)
          {
            $title = wbr(str_short($similar[$i]['topic_title'], 200));
            $topic_url = '<a title="'.$similar[$i]['topic_title'].'" href="'. "viewtopic.php?". POST_TOPIC_URL .'='. $similar[$i]['topic_id'] .'">'. $title . '</a>';

            $poster_url = "profile.php?mode=viewprofile&amp;". POST_USERS_URL .'='. $similar[$i]['user_id'];
            $similar[$i]['username'] = wbr($similar[$i]['username']);
            $poster_username = '<a class="genmed" href="'. $poster_url .'">'. $similar[$i]['username'] .'</a>';

            $forum_url = "viewforum.php?f=". $similar[$i]['forum_id'];
            $forum = '<a class="genmed" href="'. $forum_url .'">'. $similar[$i]['forum_name'] .'</a>';

          $tor_size = humn_size($similar[$i]['size']);

            $template->assign_block_vars('similar.topics', array(
            'TOPICS'    => $topic_url,
            'AUTHOR'    => $poster_username,
            'FORUM'      => $forum,
            'TOR_SIZE'    => $tor_size,
            'ROW_CLASS'   => !($i % 2) ? 'row1' : 'row2',
            ));
          }
      }
    }
// Похожие темы КОНЕЦ

в топик тпл перед <!-- IF QUICK_REPLY -->

HTML:
<!-- Похожие темы НАЧАЛО -->
    <!-- BEGIN similar -->
    <table width="100%" class="forumline">
    <thead>
    <tr>
        <th width="20%"><b>{L_FORUM}</b></th>
        <th width="65%"><b>{L_TOPIC}</b></th>
        <th width="80"><b>{L_AUTHOR}</b></th>
        <th width="80"><b>{L_SIZE}</b></th>
    </tr>
    </thead>
    <!-- BEGIN topics -->
    <tr class="tCenter {similar.topics.ROW_CLASS}">
        <td>{similar.topics.FORUM}</td>
        <td class="tLeft"><span class="topictitle">{similar.topics.TOPICS}</span></td>
        <td>{similar.topics.AUTHOR}</td>
        <td><b>{similar.topics.TOR_SIZE}</b></td>
    </tr>
    <!-- END topics -->
    </table>
    <div class="spacer_10"></div>
    <!-- END similar -->
<!-- Похожие темы КОНЕЦ -->

правда есть минус +1 запрос в топике

ланги

// Похожие темы НАЧАЛО
$lang['SIMILAR'] = 'Похожие темы';
// Похожие темы КОНЕЦ
 
Последнее редактирование:
Сверху