Number of characters, latest topic

Started by Tilbo, January 06, 2005, 07:05:10 AM

Previous topic - Next topic

Tilbo

Second topic, this time in good subforum i hope...

Problem is I want to limit the characters shown in the latest module to 10, i cant find out which pieve of code to adapt...

it is this code the problem is in...

// Recent topic list:   [board] Subject by Poster   Date
function ssi_recentTopics($num_recent = 8, $exclude_boards = array(), $output_method = 'echo')
{
   global $context, $settings, $scripturl, $txt, $db_prefix, $ID_MEMBER, $user_info, $modSettings;

   // Find all the posts in distinct topics.  Newer ones will have higher IDs.
   $request = db_query("
      SELECT
         m.posterTime, ms.subject, hxxp:m.id [nonactive]_TOPIC, hxxp:m.id [nonactive]_MEMBER, hxxp:m.id [nonactive]_MSG, hxxp:b.id [nonactive]_BOARD, hxxp:b.name [nonactive] AS bName,
         IFNULL(mem.realName, m.posterName) AS posterName, " . ($user_info['is_guest'] ? '1 AS isRead, 0 AS logTime' : '
         IFNULL(lt.logTime, IFNULL(lmr.logTime, 0)) >= GREATEST(m.posterTime, m.modifiedTime) AS isRead,
         IFNULL(lt.logTime, IFNULL(lmr.logTime, 0)) AS logTime') . "
      FROM {$db_prefix}messages AS m, {$db_prefix}topics AS t, {$db_prefix}boards AS b, {$db_prefix}messages AS ms
         LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = hxxp:m.id [nonactive]_MEMBER)" . (!$user_info['is_guest'] ? "
         LEFT JOIN {$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = hxxp:t.id [nonactive]_TOPIC AND hxxp:lt.id [nonactive]_MEMBER = $ID_MEMBER)
         LEFT JOIN {$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = hxxp:b.id [nonactive]_BOARD AND hxxp:lmr.id [nonactive]_MEMBER = $ID_MEMBER)" : '') . "
      WHERE hxxp:m.id [nonactive]_MSG >= " . ($modSettings['maxMsgID'] - 8 * $num_recent) . "
         AND hxxp:t.id [nonactive]_LAST_MSG = hxxp:m.id [nonactive]_MSG
         AND hxxp:b.id [nonactive]_BOARD = hxxp:t.id [nonactive]_BOARD" . (empty($exclude_boards) ? '' : "
         AND hxxp:b.id [nonactive]_BOARD NOT IN (" . implode(', ', $exclude_boards) . ")") . "
         AND $user_info[query_see_board]
         AND hxxp:ms.id [nonactive]_MSG = hxxp:t.id [nonactive]_FIRST_MSG
      ORDER BY hxxp:m.id [nonactive]_MSG DESC
      LIMIT $num_recent", __FILE__, __LINE__);
   $posts = array();
   while ($row = mysql_fetch_assoc($request))
   {
      // Censor the subject.
      censorText($row['subject']);

      // Build the array.
      $posts[] = array(
         'board' => array(
            'id' => $row['ID_BOARD'],
            'name' => $row['bName'],
            'href' => $scripturl . '?board=' . $row['ID_BOARD'] . '.0',
            'link' => '<a href="' . $scripturl . '?board=' . $row['ID_BOARD'] . '.0">' . $row['bName'] . '</a>'
         ),
         'topic' => $row['ID_TOPIC'],
         'poster' => array(
            'id' => $row['ID_MEMBER'],
            'name' => $row['posterName'],
            'href' => empty($row['ID_MEMBER']) ? '' : $scripturl . '?action=profile;u=' . $row['ID_MEMBER'],
            'link' => empty($row['ID_MEMBER']) ? $row['posterName'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['posterName'] . '</a>'
         ),
         'subject' => $row['subject'],
         'short_subject' => strlen(un_htmlspecialchars($row['subject'])) > 25 ? htmlspecialchars(substr(un_htmlspecialchars($row['subject']), 0, 22) . '...') : $row['subject'],
         'time' => timeformat($row['posterTime']),
         'timestamp' => $row['posterTime'],
         'href' => $scripturl . '?topic=' . $row['ID_TOPIC'],
         'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . '#msg' . $row['ID_MSG'] . '">' . $row['subject'] . '</a>',
         'new' => !empty($row['isRead']),
         'newtime' => $row['logTime']
      );
   }
   mysql_free_result($request);

   // Just return it.
   if ($output_method != 'echo' || empty($posts))
      return $posts;

   echo '
      <table border="0" class="ssi_table">';
   foreach ($posts as $post)
      echo '
         <tr>
            <td align="right" valign="top" nowrap="nowrap">
               [', $post['board']['link'], ']
            </td>
            <td valign="top">
               <a href="', $post['href'], '">', $post['subject'], '</a>
               ', $txt[525], ' ', $post['poster']['link'], '
               ', $post['new'] ? '' : '<a href="' . $scripturl . '?topic=' . $post['topic'] . '.from' . $post['newtime'] . ';topicseen#new"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="' . $txt[302] . '" border="0" /></a>', '
            </td>
            <td align="right" nowrap="nowrap">
               ', $post['time'], '
            </td>
         </tr>';
   echo '
      </table>';
}

// Show the top poster's name and profile link.
function ssi_topPoster($topNumber = 1, $output_method = 'echo')
{
   global $db_prefix, $scripturl;


Thank to the one who can help me, with this probably small problem!

Orstio

No, do not change SSI.php.

In mod_smf_recentTopics.php, line 14 should say:

$num_recent = 5;

Just change that to 10 instead of 5.


Advertisement: