TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,963
  • Latest: BiZaJe
Stats
  • Total Posts: 195,913
  • Total Topics: 21,308
  • Online today: 884
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 1
  • Guests: 587
  • Total: 588
  • @rjen

Recent topics for SMF2

Started by IchBin, February 22, 2010, 07:53:26 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

leftezi

The page numbers links did not working properly. They redirect to wrong topics.
I tried to remove the page number section by deleting some code, with success, but i get this error in forum errors log:

Undefined variable: pages
File: ....Themes/default/TPsubs.template.php(127) : eval()'d code
Line: 385


The change i have tried is this:

// Show links to all the pages?
         if (count($tmppages) <= 0)
            $pages = '« ' . implode(' ', $tmppages);
      }
      else
         $pages = '';


Sure it' is the wrong way. Can someone tel me the right way to remove the page numbers?  :)

IchBin

You need to post the code you are using so we can see what is going on. So you just want to remove the page number section?

leftezi

Yes  :) The page numbers and ths "Prev" - "Next"
Thanks

global $context, $settings, $scripturl, $txt, $db_prefix, $user_info, $modSettings, $user_profile, $smcFunc;

//////////////////////////////////////////// ---------- Unconditional Exclude
//   
   $exclude_boards = array(28,87,137,85,138,83,32,24,27,44,117,128);   // KEEP (to preserve variable declaration)
//   $exclude_boards = array(5);   //  Exclude single board
//     $exclude_boards = array(55,69);   //  Exclude multiple boards
   $ex_board_clause = !empty($exclude_boards) ? ' AND b.id_board NOT IN (' . implode(', ', $exclude_boards) . ')' : '';
//   
//   

//////////////////////////////////////////// ---------- Use in TP PHP Article (no title or frame from theme)
//   This will give most recent XX posted to topics -OR-
//   most recent XX unreplied to topics -OR-
//   topics posted to in last XX hours -OR-
//   most recent XX topics on topic notify list
//   
//   Sorts by most recent reply (descending; most recent first) -OR-
//            creation order (descending; most recent first)
//   
//   All in the detailed topic format
//   
//   
//   Default
//   index.php?page=##
//   most recent posted to topics - will list
//   number equal to  $settings['number_recent_posts']
//   
//   index.php?page=##;count=50 or index.php?page=##;type=last;count=50
//   50 most recently posted to topics
//   
//   index.php?page=##;type=unreplied or index.php?page=##;type=unreplied;count=50
//   Most recent unreplied to topics - will
//   list number specified in 'count' or default to
//   number equal to  $settings['number_recent_posts']
//   
//   index.php?page=##;type=hours or index.php?page=##;type=hours;count=12
//   Topics posted to in last number of hours
//   specified in 'count' or default to 24.
//   
//   index.php?page=##;type=notify or index.php?page=##;type=notify;count=50
//   Topics in topic notifcation list up to number
//   specified in 'count' or a maximum of 100 topics.
//   
//   *** Admins Only ***
//   index.php?page=##;type=notify;user=XXX or index.php?page=##;type=notify;user=XXX;count=50
//   Topics in topic notifcation list of specified user up to number
//   specified in 'count' or a maximum of 100 topics.
//   
//   index.php?page=##;type=started or index.php?page=##;type=started;count=50
//   Topics started by current user list up to number
//   specified in 'count' or a maximum of 100 topics.
//   
//   *** Admins Only ***
//   index.php?page=##;type=notify;user=XXX or index.php?page=##;type=started;user=XXX;count=50
//   Topics started by specified user up to number
//   specified in 'count' or a maximum of 100 topics.
//   
//   Add argument order=create to sort by topic creation sequence (most recent first)
//   rather than by last reply sequence

   $do_query = 1;

//////////////////////////////////////////// ---------- Poor Man's Global Announcements Block (center block - no Title/Frame)
//   Delete documentation comments above and marked section below
//
//   $announce_topics = array(254, 568, 675, 678); // Topic ID's to be 'Announced'
//
//   $heading = '<center>Announcements<center>';
//   $where_clause = 't.ID_TOPIC IN (' . implode(', ', $announce_topics) . ')';
//   $limit_clause = '';
//   $order_clause = 't.ID_LAST_MSG DESC';
////////////////////////////////////////////   

//////////////////////////////////////////// ---------- Last 5 Topics Started by User Block (center block - no Title/Frame)
//   Delete documentation comments above and marked section below
//
//   $heading = 'Most Recent Topics You Started';
//   $where_clause = 'ms.ID_MEMBER = '.$ID_MEMBER;
//   $limit_clause = 'LIMIT 5';
//   $order_clause = 't.ID_FIRST_MSG DESC';
////////////////////////////////////////////   

//////////////////////////////////////////// ---------- Boardindex Most Recent Topics Arguments
//
//   Comment out the Info Center's Most Recent Posts Code and Insert this
//   to show Most Recent Topics in full detail style instead
//
//   $list_count = $settings['number_recent_posts'];
//   $heading = 'Most Recently Posted To Topics';
//   $where_clause = 't.ID_LAST_MSG >= ' . ($modSettings['maxMsgID'] - 50 * min($list_count, 5));
//   $limit_clause = 'LIMIT ' . $list_count;
//   $order_clause = 't.ID_LAST_MSG DESC';
////////////////////////////////////////////   

////////////////////////////////////////////  ------ Remove down to next mark to use in block/boardindex ------
//
   if (empty($settings['number_recent_posts']))
      $number_recent_posts = 12;
   else
      $number_recent_posts = $settings['number_recent_posts'];

        if( isset($_GET['type']) )
      $list_type = $_GET['type'];
   else
      $list_type = 'last';

        if( isset($_GET['count']) )
      $list_count = $_GET['count'];
   else
   {
      $list_count = $number_recent_posts;
      if ($list_type == 'notify')
         $list_count = 100;
      elseif ($list_type == 'hours')
         $list_count = 24;
   }

   if ($list_count <= 0)
   {
      $list_count = $number_recent_posts;
      if ($list_type == 'hours')
         $list_count = 24;
   }

   if ($list_count > 100)
      $list_count = 100;

        if( isset($_GET['order']) )
      $list_order = $_GET['order'];
   else
      $list_order = 'lastpost';

        if( $list_order == 'create' )
      $order_clause = 't.id_first_msg DESC';
   else
      $order_clause = 't.id_last_msg DESC';

   if ($list_type == 'hours')
   {
      $list_from = strtotime($list_count.' hours ago');
      $where_clause = 'ml.poster_time >= ' . $list_from;
      $limit_clause = ' ';
      $heading = 'Topics Posted To In Last '. $list_count . ' Hours';
   }
   elseif ($list_type == 'unreplied')
   {
      $where_clause = 't.num_replies = 0';
      if ($list_count == 0)
      {
         $limit_clause = ' ';
         $heading = 'Unreplied To Topics';
      }
      else
      {
      $limit_clause = 'LIMIT ' . $list_count;
      $heading = $list_count . ' Most Recent Unreplied To Topics';
      }
   }
   elseif ($list_type == 'notify')
   {
      if (isset($_GET['user']) && $user_info['is_admin'])
      {
         $watched_topics = array();
         $request = $smcFunc['db_query']("", "SELECT id_topic FROM ".$db_prefix."log_notify
                                 WHERE id_member = {int:user_id}
                                 AND id_board = 0",
                                 array('user_id' => $_GET['user']));
         while ($row = $smcFunc['db_fetch_assoc']($request))
            $watched_topics[] = $row['id_topic'];
         $smcFunc['db_free_result']($request);
         $heading = $list_count . ' Most Recent Topics Being Watched by User # '.$_GET['user'];
         $where_clause = 't.id_topic IN (' . implode(', ', $watched_topics) . ')';
         $limit_clause = 'LIMIT ' . $list_count;
         if (empty($watched_topics))
            $do_query = 0;
      }
      else
      {
         $watched_topics = array();
         $request = $smcFunc['db_query']("", "SELECT id_topic FROM ".$db_prefix."log_notify
                                 WHERE id_member = {int:id_member}
                                 AND id_board = 0",
                                 array('id_member' => $user_info['id']));
         while ($row = $smcFunc['db_fetch_assoc']($request))
            $watched_topics[] = $row['id_topic'];
         $smcFunc['db_free_result']($request);
         $heading = $list_count . ' Most Recent Topics Being Watched';
         $where_clause = 't.id_topic IN (' . implode(', ', $watched_topics) . ')';
         $limit_clause = 'LIMIT ' . $list_count;
         if (empty($watched_topics))
            $do_query = 0;
      }
   }
   elseif ($list_type == 'started')
   {
      if (isset($_GET['user']) && $user_info['is_admin'])
      {
         $where_clause = 'ms.id_member = '.$_GET['user'];
         $limit_clause = 'LIMIT ' . $list_count;
              if( $list_order == 'create' )
         {
            $order_clause = 't.id_first_msg DESC';
            $heading = 'Most Recent Topics Started by User '.$_GET['user'];
         }
         else
         {
            $order_clause = 't.id_last_msg DESC';
            $heading = 'Most Recently Posted To Topics Started by User '.$_GET['user'];
         }
      }
      else
      {
         $where_clause = 'ms.id_member = '.$user_info['id'];
         $limit_clause = 'LIMIT ' . $list_count;
              if( $list_order == 'create' )
         {
            $order_clause = 't.id_first_msg DESC';
            $heading = 'Most Recent Topics You Started';
         }
         else
         {
            $order_clause = 't.id_last_msg DESC';
            $heading = 'Most Recently Posted To Topics You Started';
         }
      }
   }
   else
   {
      $where_clause = 't.id_last_msg >= ' . ($modSettings['maxMsgID'] - 90 * min($list_count, 5));
      $limit_clause = 'LIMIT ' . $list_count;
      $heading = $list_count . ' Most Recently Posted To Topics';
   }
//
////////////////////////////////////////////  ------ Remove up to first mark to use in block/boardindex ------

   $stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless');
   $icon_sources = array();
   foreach ($stable_icons as $icon)
      $icon_sources[$icon] = 'images_url';

   $groupcolors = array();
   $request = $smcFunc['db_query']("", "SELECT id_group, online_color FROM ".$db_prefix."membergroups",array());
   while ($row = $smcFunc['db_fetch_assoc']($request))
      $groupcolors[$row['id_group']] = $row['online_color'];
   $smcFunc['db_free_result']($request);

   $topics = array();

   if ($do_query == 1)
   {
      $request = $smcFunc['db_query']("", "
      SELECT
            ms.subject AS firstSubject, ms.poster_time AS firstPosterTime, ms.id_topic, t.id_last_msg, t.id_board, b.name AS bname,
            t.num_replies, t.num_views, ms.id_member AS ID_FIRST_MEMBER, ml.id_member AS ID_LAST_MEMBER,
            ml.poster_time AS lastPosterTime, IFNULL(mems.real_name, ms.poster_name) AS firstPosterName,
            IFNULL(meml.real_name, ml.poster_name) AS lastPosterName,
            mems.id_group as mems_group, meml.id_group as meml_group,
            ml.subject AS lastSubject, b.member_groups,
            ml.icon AS lastIcon, ms.icon AS firstIcon, t.id_poll, t.is_sticky, t.locked, ml.modified_time AS lastModifiedTime,
            LEFT(ml.body, 384) AS lastBody, LEFT(ms.body, 384) AS firstBody,
            ml.smileys_enabled AS lastSmileys, ms.smileys_enabled AS firstSmileys, t.id_first_msg,"
            . ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' : '
            IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= ml.id_msg_modified AS isRead,
            IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . "
         FROM (".$db_prefix."messages AS ms, ".$db_prefix."messages AS ml, ".$db_prefix."topics AS t, ".$db_prefix."boards AS b)
            LEFT JOIN ".$db_prefix."members AS mems ON (mems.id_member = ms.id_member)
            LEFT JOIN ".$db_prefix."members AS meml ON (meml.id_member = ml.id_member)
            LEFT JOIN ".$db_prefix."log_topics AS lt ON (lt.id_topic = t.id_topic AND lt.id_member = ".$user_info['id'].")
            LEFT JOIN ".$db_prefix."log_mark_read AS lmr ON (lmr.id_board = t.id_board AND lmr.id_member = ".$user_info['id'].")
         WHERE " . $where_clause . $ex_board_clause . "
            AND t.id_topic = ms.id_topic
            AND b.id_board = t.id_board" . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? " AND b.id_board != ".$modSettings['recycle_board'] : "") . "
            AND ms.id_msg = t.id_first_msg
            AND ml.id_msg = t.id_last_msg
            AND " . $user_info['query_see_board'] . "
         ORDER BY " . $order_clause . " " . $limit_clause,
       array());


   $topic_ids = array();
   while ($row = $smcFunc['db_fetch_assoc']($request))
   {
      if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0')
         continue;

      $topic_ids[] = $row['id_topic'];

      // Clip the strings first because censoring is slow :/. (for some reason?)
      $row['firstBody'] = strip_tags(strtr(parse_bbc($row['firstBody'], $row['firstSmileys'], $row['id_first_msg']), array('<br />' => '
')));
      if (strlen($row['firstBody']) > 128)
         $row['firstBody'] = substr($row['firstBody'], 0, 128) . '...';
      $row['lastBody'] = strip_tags(strtr(parse_bbc($row['lastBody'], $row['lastSmileys'], $row['id_last_msg']), array('<br />' => '
')));
      if (strlen($row['lastBody']) > 128)
         $row['lastBody'] = substr($row['lastBody'], 0, 128) . '...';

         $row['lastSubject'] = $row['firstSubject'];
         $row['lastBody'] = $row['firstBody'];

      // Decide how many pages the topic should have.
      $topic_length = $row['num_replies'] + 1;
      if ($topic_length > $modSettings['defaultMaxMessages'])
      {
         $tmppages = array();
         $tmpa = 1;
         for ($tmpb = 0; $tmpb < $topic_length; $tmpb += $modSettings['defaultMaxMessages'])
         {
            $tmppages[] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . $tmpb . ';topicseen">' . $tmpa . '</a>';
            $tmpa++;
         }
// Show links to all the pages?
         if (count($tmppages) <= 0)
            $pages = '« ' . implode(' ', $tmppages);
      }
      else
         $pages = '';

      // We need to check the topic icons exist... you can never be too sure!
      if (empty($modSettings['messageIconChecks_disable']))
      {
         // First icon first... as you'd expect.
         if (!isset($icon_sources[$row['firstIcon']]))
            $icon_sources[$row['firstIcon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['firstIcon'] . '.gif') ? 'images_url' : 'default_images_url';
         // Last icon... last... duh.
         if (!isset($icon_sources[$row['lastIcon']]))
            $icon_sources[$row['lastIcon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['lastIcon'] . '.gif') ? 'images_url' : 'default_images_url';
      }

      $color_start = !empty($groupcolors[$row['mems_group']]) ? $groupcolors[$row['mems_group']] : '';
      $color_last = !empty($groupcolors[$row['meml_group']]) ? $groupcolors[$row['meml_group']] : '';

      // And build the array.
      $topics[$row['id_topic']] = array(
         'id' => $row['id_topic'],
         'first_post' => array(
            'id' => $row['id_first_msg'],
            'member' => array(
               'name' => $row['firstPosterName'],
               'id' => $row['ID_FIRST_MEMBER'],
               'href' => $scripturl . '?action=profile;u=' . $row['ID_FIRST_MEMBER'],
               'link' => !empty($row['ID_FIRST_MEMBER']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_FIRST_MEMBER'] . '" title="' . $txt['profile_of'] . ' ' . $row['firstPosterName'] . '">' . '<font color="' . $color_start . '">' . $row['firstPosterName'] . '</font>' . '</a>' : $row['firstPosterName']
            ),
            'time' => timeformat($row['firstPosterTime']),
            'timestamp' => forum_time(true, $row['firstPosterTime']),
            'subject' => $row['firstSubject'],
            'preview' => $row['firstBody'],
            'icon' => $row['firstIcon'],
            'icon_url' => $settings[$icon_sources[$row['firstIcon']]] . '/post/' . $row['firstIcon'] . '.gif',
            'href' => $scripturl . '?topic=' . $row['id_topic'] . '.0;topicseen',
            'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;topicseen">' . $row['firstSubject'] . '</a>'
         ),
         'last_post' => array(
            'id' => $row['id_last_msg'],
            'member' => array(
               'name' => $row['lastPosterName'],
               'id' => $row['ID_LAST_MEMBER'],
               'href' => $scripturl . '?action=profile;u=' . $row['ID_LAST_MEMBER'],
               'link' => !empty($row['ID_LAST_MEMBER']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_LAST_MEMBER'] . '">' . '<font color="' . $color_last . '">' . $row['lastPosterName'] . '</font>' . '</a>' : $row['lastPosterName']
            ),
            'time' => timeformat($row['lastPosterTime']),
            'timestamp' => forum_time(true, $row['lastPosterTime']),
            'subject' => $row['lastSubject'],
            'preview' => $row['lastBody'],
            'icon' => $row['lastIcon'],
            'icon_url' => $settings[$icon_sources[$row['lastIcon']]] . '/post/' . $row['lastIcon'] . '.gif',
            'href' => $scripturl . '?topic=' . $row['id_topic'] . ($row['num_replies'] == 0 ? '.0' : '.msg' . $row['id_last_msg']) . ';topicseen#msg' . $row['id_last_msg'],
            'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . ($row['num_replies'] == 0 ? '.0' : '.msg' . $row['id_last_msg']) . ';topicseen#msg' . $row['id_last_msg'] . '">' . $row['lastSubject'] . '</a>'
         ),
         'new' => $row['isRead'],
         'new_from' => $row['new_from'],
         'new_href' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['new_from'] . ';topicseen#new',
         'href' => $scripturl . '?topic=' . $row['id_topic'] . ($row['num_replies'] == 0 ? '.0' : '.msg' . $row['new_from']) . ';topicseen' . ($row['num_replies'] == 0 ? '' : 'new'),
         'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . ($row['num_replies'] == 0 ? '.0' : '.msg' . $row['new_from']) . ';topicseen#msg' . $row['new_from'] . '">' . $row['firstSubject'] . '</a>',
         'is_sticky' => !empty($modSettings['enableStickyTopics']) && !empty($row['isSticky']),
         'is_locked' => !empty($row['locked']),
         'is_poll' => $modSettings['pollMode'] == '1' && $row['id_poll'] > 0,
         'is_hot' => $row['num_replies'] >= $modSettings['hotTopicPosts'],
         'is_very_hot' => $row['num_replies'] >= $modSettings['hotTopicVeryPosts'],
         'is_posted_in' => false,
         'icon' => $row['firstIcon'],
         'icon_url' => $settings[$icon_sources[$row['firstIcon']]] . '/post/' . $row['firstIcon'] . '.gif',
         'subject' => $row['firstSubject'],
         'pages' => $pages,
         'replies' => $row['num_replies'],
         'views' => $row['num_views'],
         '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>'
         )
      );

      determineTopicClass($topics[$row['id_topic']]);
   }
   $smcFunc['db_free_result']($request);

   if (!empty($modSettings['enableParticipation']) && !empty($topic_ids))
   {
      $result = $smcFunc['db_query']("", "
         SELECT id_topic
         FROM ".$db_prefix."messages
         WHERE id_topic IN (" . implode(', ', $topic_ids) . ")
            AND id_member = {int:id_member}",
         array('id_member' => $user_info['id']));
      while ($row = $smcFunc['db_fetch_assoc']($result))
      {
         if (empty($topics[$row['id_topic']]['is_posted_in']))
         {
            $topics[$row['id_topic']]['is_posted_in'] = true;
            $topics[$row['id_topic']]['class'] = 'my_' . $topics[$row['id_topic']]['class'];
         }
      }
      $smcFunc['db_free_result']($result);
   }

   }

if (!empty($topics))
    {
    echo '
        <div class="tborder" ', $context['browser']['needs_size_fix'] && !$context['browser']['is_ie6'] ? 'style="width: 100%;margin:0px;"' : 'style="margin:0px;"', '>
            <table border="0" width="100%" cellspacing="1" cellpadding="1" class="bordercolor">
                <tr>';


    echo '
                </tr>';

    echo '
            <tr class="titlebg">
               <td width="10%" colspan="2"> </td>
               <td>', $txt['subject'], '
               </td><td width="14%">', $txt['posted_by'], '
               </td><td width="4%" align="center">', $txt['replies'], '
               </td><td width="4%" align="center">', $txt['views'], '
               </td><td width="24%">', $txt['last_post'], '
               </td>
            </tr>';

   foreach ($topics as $topic)
   {
      // Do we want to seperate the sticky and lock status out?
      if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'sticky') !== false)
         $topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_sticky'));
      if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'locked') !== false)
         $topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_locked'));

      echo '
            <tr>
               <td class="windowbg2" valign="middle" align="center" width="6%">
                  <img src="' . $settings['images_url'] . '/topic/' . $topic['class'] . '.gif" alt="" />
               </td><td class="windowbg2" valign="middle" align="center" width="4%">
                  <img src="' . $topic['first_post']['icon_url'] . '" alt="" align="middle" />
               </td><td class="windowbg' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '3' : '' , '" width="48%" valign="middle">' , $topic['is_locked'] && !empty($settings['seperate_sticky_lock']) ? '
                  <img src="' . $settings['images_url'] . '/icons/quick_lock.gif" align="right" alt="" style="margin: 0;" />' : '' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '
                  <img src="' . $settings['images_url'] . '/icons/show_sticky.gif" align="right" alt="" style="margin: 0;" />' : '', $topic['first_post']['link'];
               if ($topic['new'] == 0)
                  {
                  echo '<a href="', $topic['new_href'], '"> <img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt['seconds_with'], '" /></a>';
                  }
                echo '
               <span class="smalltext">', $topic['pages'], '<br>', $txt['in'], ' ', $topic['board']['link'], '</span></td>
               <td class="windowbg2" valign="middle" width="14%">
                  ', $topic['first_post']['member']['link'], '</td>
               <td class="windowbg" valign="middle" width="4%" align="center">
                  ', $topic['replies'], '</td>
               <td class="windowbg" valign="middle" width="4%" align="center">
                  ', $topic['views'], '</td>
               <td class="windowbg2" valign="middle" width="22%">
                  <a href="', $topic['last_post']['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt['last_post'], '" title="', $txt['last_post'], '" style="float: right;" /></a>
                  <span class="smalltext">
                     ', $topic['last_post']['time'], '<br />
                     ', $txt['by'], ' ', $topic['last_post']['member']['link'], '
                  </span>
               </td>
            </tr>';
   }

    echo '</table></div>';

    }
   else
       echo '<b><u>'.$heading.'<br><br>No Topics Match Search Criteria</u></b>';




IchBin

Think this should do it. Let me know if I missed something.

global $context, $settings, $scripturl, $txt, $db_prefix, $user_info, $modSettings, $user_profile, $smcFunc;

//////////////////////////////////////////// ---------- Unconditional Exclude
//   
   $exclude_boards = array(28,87,137,85,138,83,32,24,27,44,117,128);   // KEEP (to preserve variable declaration)
//   $exclude_boards = array(5);   //  Exclude single board
//     $exclude_boards = array(55,69);   //  Exclude multiple boards
   $ex_board_clause = !empty($exclude_boards) ? ' AND b.id_board NOT IN (' . implode(', ', $exclude_boards) . ')' : '';
//   
//   

//////////////////////////////////////////// ---------- Use in TP PHP Article (no title or frame from theme)
//   This will give most recent XX posted to topics -OR-
//   most recent XX unreplied to topics -OR-
//   topics posted to in last XX hours -OR-
//   most recent XX topics on topic notify list
//   
//   Sorts by most recent reply (descending; most recent first) -OR-
//            creation order (descending; most recent first)
//   
//   All in the detailed topic format
//   
//   
//   Default
//   index.php?page=##
//   most recent posted to topics - will list
//   number equal to  $settings['number_recent_posts']
//   
//   index.php?page=##;count=50 or index.php?page=##;type=last;count=50
//   50 most recently posted to topics
//   
//   index.php?page=##;type=unreplied or index.php?page=##;type=unreplied;count=50
//   Most recent unreplied to topics - will
//   list number specified in 'count' or default to
//   number equal to  $settings['number_recent_posts']
//   
//   index.php?page=##;type=hours or index.php?page=##;type=hours;count=12
//   Topics posted to in last number of hours
//   specified in 'count' or default to 24.
//   
//   index.php?page=##;type=notify or index.php?page=##;type=notify;count=50
//   Topics in topic notifcation list up to number
//   specified in 'count' or a maximum of 100 topics.
//   
//   *** Admins Only ***
//   index.php?page=##;type=notify;user=XXX or index.php?page=##;type=notify;user=XXX;count=50
//   Topics in topic notifcation list of specified user up to number
//   specified in 'count' or a maximum of 100 topics.
//   
//   index.php?page=##;type=started or index.php?page=##;type=started;count=50
//   Topics started by current user list up to number
//   specified in 'count' or a maximum of 100 topics.
//   
//   *** Admins Only ***
//   index.php?page=##;type=notify;user=XXX or index.php?page=##;type=started;user=XXX;count=50
//   Topics started by specified user up to number
//   specified in 'count' or a maximum of 100 topics.
//   
//   Add argument order=create to sort by topic creation sequence (most recent first)
//   rather than by last reply sequence

   $do_query = 1;

//////////////////////////////////////////// ---------- Poor Man's Global Announcements Block (center block - no Title/Frame)
//   Delete documentation comments above and marked section below
//
//   $announce_topics = array(254, 568, 675, 678); // Topic ID's to be 'Announced'
//
//   $heading = '<center>Announcements<center>';
//   $where_clause = 't.ID_TOPIC IN (' . implode(', ', $announce_topics) . ')';
//   $limit_clause = '';
//   $order_clause = 't.ID_LAST_MSG DESC';
////////////////////////////////////////////   

//////////////////////////////////////////// ---------- Last 5 Topics Started by User Block (center block - no Title/Frame)
//   Delete documentation comments above and marked section below
//
//   $heading = 'Most Recent Topics You Started';
//   $where_clause = 'ms.ID_MEMBER = '.$ID_MEMBER;
//   $limit_clause = 'LIMIT 5';
//   $order_clause = 't.ID_FIRST_MSG DESC';
////////////////////////////////////////////   

//////////////////////////////////////////// ---------- Boardindex Most Recent Topics Arguments
//
//   Comment out the Info Center's Most Recent Posts Code and Insert this
//   to show Most Recent Topics in full detail style instead
//
//   $list_count = $settings['number_recent_posts'];
//   $heading = 'Most Recently Posted To Topics';
//   $where_clause = 't.ID_LAST_MSG >= ' . ($modSettings['maxMsgID'] - 50 * min($list_count, 5));
//   $limit_clause = 'LIMIT ' . $list_count;
//   $order_clause = 't.ID_LAST_MSG DESC';
////////////////////////////////////////////   

////////////////////////////////////////////  ------ Remove down to next mark to use in block/boardindex ------
//
   if (empty($settings['number_recent_posts']))
      $number_recent_posts = 12;
   else
      $number_recent_posts = $settings['number_recent_posts'];

        if( isset($_GET['type']) )
      $list_type = $_GET['type'];
   else
      $list_type = 'last';

        if( isset($_GET['count']) )
      $list_count = $_GET['count'];
   else
   {
      $list_count = $number_recent_posts;
      if ($list_type == 'notify')
         $list_count = 100;
      elseif ($list_type == 'hours')
         $list_count = 24;
   }

   if ($list_count <= 0)
   {
      $list_count = $number_recent_posts;
      if ($list_type == 'hours')
         $list_count = 24;
   }

   if ($list_count > 100)
      $list_count = 100;

        if( isset($_GET['order']) )
      $list_order = $_GET['order'];
   else
      $list_order = 'lastpost';

        if( $list_order == 'create' )
      $order_clause = 't.id_first_msg DESC';
   else
      $order_clause = 't.id_last_msg DESC';

   if ($list_type == 'hours')
   {
      $list_from = strtotime($list_count.' hours ago');
      $where_clause = 'ml.poster_time >= ' . $list_from;
      $limit_clause = ' ';
      $heading = 'Topics Posted To In Last '. $list_count . ' Hours';
   }
   elseif ($list_type == 'unreplied')
   {
      $where_clause = 't.num_replies = 0';
      if ($list_count == 0)
      {
         $limit_clause = ' ';
         $heading = 'Unreplied To Topics';
      }
      else
      {
      $limit_clause = 'LIMIT ' . $list_count;
      $heading = $list_count . ' Most Recent Unreplied To Topics';
      }
   }
   elseif ($list_type == 'notify')
   {
      if (isset($_GET['user']) && $user_info['is_admin'])
      {
         $watched_topics = array();
         $request = $smcFunc['db_query']("", "SELECT id_topic FROM ".$db_prefix."log_notify
                                 WHERE id_member = {int:user_id}
                                 AND id_board = 0",
                                 array('user_id' => $_GET['user']));
         while ($row = $smcFunc['db_fetch_assoc']($request))
            $watched_topics[] = $row['id_topic'];
         $smcFunc['db_free_result']($request);
         $heading = $list_count . ' Most Recent Topics Being Watched by User # '.$_GET['user'];
         $where_clause = 't.id_topic IN (' . implode(', ', $watched_topics) . ')';
         $limit_clause = 'LIMIT ' . $list_count;
         if (empty($watched_topics))
            $do_query = 0;
      }
      else
      {
         $watched_topics = array();
         $request = $smcFunc['db_query']("", "SELECT id_topic FROM ".$db_prefix."log_notify
                                 WHERE id_member = {int:id_member}
                                 AND id_board = 0",
                                 array('id_member' => $user_info['id']));
         while ($row = $smcFunc['db_fetch_assoc']($request))
            $watched_topics[] = $row['id_topic'];
         $smcFunc['db_free_result']($request);
         $heading = $list_count . ' Most Recent Topics Being Watched';
         $where_clause = 't.id_topic IN (' . implode(', ', $watched_topics) . ')';
         $limit_clause = 'LIMIT ' . $list_count;
         if (empty($watched_topics))
            $do_query = 0;
      }
   }
   elseif ($list_type == 'started')
   {
      if (isset($_GET['user']) && $user_info['is_admin'])
      {
         $where_clause = 'ms.id_member = '.$_GET['user'];
         $limit_clause = 'LIMIT ' . $list_count;
              if( $list_order == 'create' )
         {
            $order_clause = 't.id_first_msg DESC';
            $heading = 'Most Recent Topics Started by User '.$_GET['user'];
         }
         else
         {
            $order_clause = 't.id_last_msg DESC';
            $heading = 'Most Recently Posted To Topics Started by User '.$_GET['user'];
         }
      }
      else
      {
         $where_clause = 'ms.id_member = '.$user_info['id'];
         $limit_clause = 'LIMIT ' . $list_count;
              if( $list_order == 'create' )
         {
            $order_clause = 't.id_first_msg DESC';
            $heading = 'Most Recent Topics You Started';
         }
         else
         {
            $order_clause = 't.id_last_msg DESC';
            $heading = 'Most Recently Posted To Topics You Started';
         }
      }
   }
   else
   {
      $where_clause = 't.id_last_msg >= ' . ($modSettings['maxMsgID'] - 90 * min($list_count, 5));
      $limit_clause = 'LIMIT ' . $list_count;
      $heading = $list_count . ' Most Recently Posted To Topics';
   }
//
////////////////////////////////////////////  ------ Remove up to first mark to use in block/boardindex ------

   $stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless');
   $icon_sources = array();
   foreach ($stable_icons as $icon)
      $icon_sources[$icon] = 'images_url';

   $groupcolors = array();
   $request = $smcFunc['db_query']("", "SELECT id_group, online_color FROM ".$db_prefix."membergroups",array());
   while ($row = $smcFunc['db_fetch_assoc']($request))
      $groupcolors[$row['id_group']] = $row['online_color'];
   $smcFunc['db_free_result']($request);

   $topics = array();

   if ($do_query == 1)
   {
      $request = $smcFunc['db_query']("", "
      SELECT
            ms.subject AS firstSubject, ms.poster_time AS firstPosterTime, ms.id_topic, t.id_last_msg, t.id_board, b.name AS bname,
            t.num_replies, t.num_views, ms.id_member AS ID_FIRST_MEMBER, ml.id_member AS ID_LAST_MEMBER,
            ml.poster_time AS lastPosterTime, IFNULL(mems.real_name, ms.poster_name) AS firstPosterName,
            IFNULL(meml.real_name, ml.poster_name) AS lastPosterName,
            mems.id_group as mems_group, meml.id_group as meml_group,
            ml.subject AS lastSubject, b.member_groups,
            ml.icon AS lastIcon, ms.icon AS firstIcon, t.id_poll, t.is_sticky, t.locked, ml.modified_time AS lastModifiedTime,
            LEFT(ml.body, 384) AS lastBody, LEFT(ms.body, 384) AS firstBody,
            ml.smileys_enabled AS lastSmileys, ms.smileys_enabled AS firstSmileys, t.id_first_msg,"
            . ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' : '
            IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= ml.id_msg_modified AS isRead,
            IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . "
         FROM (".$db_prefix."messages AS ms, ".$db_prefix."messages AS ml, ".$db_prefix."topics AS t, ".$db_prefix."boards AS b)
            LEFT JOIN ".$db_prefix."members AS mems ON (mems.id_member = ms.id_member)
            LEFT JOIN ".$db_prefix."members AS meml ON (meml.id_member = ml.id_member)
            LEFT JOIN ".$db_prefix."log_topics AS lt ON (lt.id_topic = t.id_topic AND lt.id_member = ".$user_info['id'].")
            LEFT JOIN ".$db_prefix."log_mark_read AS lmr ON (lmr.id_board = t.id_board AND lmr.id_member = ".$user_info['id'].")
         WHERE " . $where_clause . $ex_board_clause . "
            AND t.id_topic = ms.id_topic
            AND b.id_board = t.id_board" . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? " AND b.id_board != ".$modSettings['recycle_board'] : "") . "
            AND ms.id_msg = t.id_first_msg
            AND ml.id_msg = t.id_last_msg
            AND " . $user_info['query_see_board'] . "
         ORDER BY " . $order_clause . " " . $limit_clause,
       array());


   $topic_ids = array();
   while ($row = $smcFunc['db_fetch_assoc']($request))
   {
      if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0')
         continue;

      $topic_ids[] = $row['id_topic'];

      // Clip the strings first because censoring is slow :/. (for some reason?)
      $row['firstBody'] = strip_tags(strtr(parse_bbc($row['firstBody'], $row['firstSmileys'], $row['id_first_msg']), array('<br />' => '
')));
      if (strlen($row['firstBody']) > 128)
         $row['firstBody'] = substr($row['firstBody'], 0, 128) . '...';
      $row['lastBody'] = strip_tags(strtr(parse_bbc($row['lastBody'], $row['lastSmileys'], $row['id_last_msg']), array('<br />' => '
')));
      if (strlen($row['lastBody']) > 128)
         $row['lastBody'] = substr($row['lastBody'], 0, 128) . '...';

         $row['lastSubject'] = $row['firstSubject'];
         $row['lastBody'] = $row['firstBody'];

      // We need to check the topic icons exist... you can never be too sure!
      if (empty($modSettings['messageIconChecks_disable']))
      {
         // First icon first... as you'd expect.
         if (!isset($icon_sources[$row['firstIcon']]))
            $icon_sources[$row['firstIcon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['firstIcon'] . '.gif') ? 'images_url' : 'default_images_url';
         // Last icon... last... duh.
         if (!isset($icon_sources[$row['lastIcon']]))
            $icon_sources[$row['lastIcon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['lastIcon'] . '.gif') ? 'images_url' : 'default_images_url';
      }

      $color_start = !empty($groupcolors[$row['mems_group']]) ? $groupcolors[$row['mems_group']] : '';
      $color_last = !empty($groupcolors[$row['meml_group']]) ? $groupcolors[$row['meml_group']] : '';

      // And build the array.
      $topics[$row['id_topic']] = array(
         'id' => $row['id_topic'],
         'first_post' => array(
            'id' => $row['id_first_msg'],
            'member' => array(
               'name' => $row['firstPosterName'],
               'id' => $row['ID_FIRST_MEMBER'],
               'href' => $scripturl . '?action=profile;u=' . $row['ID_FIRST_MEMBER'],
               'link' => !empty($row['ID_FIRST_MEMBER']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_FIRST_MEMBER'] . '" title="' . $txt['profile_of'] . ' ' . $row['firstPosterName'] . '">' . '<font color="' . $color_start . '">' . $row['firstPosterName'] . '</font>' . '</a>' : $row['firstPosterName']
            ),
            'time' => timeformat($row['firstPosterTime']),
            'timestamp' => forum_time(true, $row['firstPosterTime']),
            'subject' => $row['firstSubject'],
            'preview' => $row['firstBody'],
            'icon' => $row['firstIcon'],
            'icon_url' => $settings[$icon_sources[$row['firstIcon']]] . '/post/' . $row['firstIcon'] . '.gif',
            'href' => $scripturl . '?topic=' . $row['id_topic'] . '.0;topicseen',
            'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;topicseen">' . $row['firstSubject'] . '</a>'
         ),
         'last_post' => array(
            'id' => $row['id_last_msg'],
            'member' => array(
               'name' => $row['lastPosterName'],
               'id' => $row['ID_LAST_MEMBER'],
               'href' => $scripturl . '?action=profile;u=' . $row['ID_LAST_MEMBER'],
               'link' => !empty($row['ID_LAST_MEMBER']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_LAST_MEMBER'] . '">' . '<font color="' . $color_last . '">' . $row['lastPosterName'] . '</font>' . '</a>' : $row['lastPosterName']
            ),
            'time' => timeformat($row['lastPosterTime']),
            'timestamp' => forum_time(true, $row['lastPosterTime']),
            'subject' => $row['lastSubject'],
            'preview' => $row['lastBody'],
            'icon' => $row['lastIcon'],
            'icon_url' => $settings[$icon_sources[$row['lastIcon']]] . '/post/' . $row['lastIcon'] . '.gif',
            'href' => $scripturl . '?topic=' . $row['id_topic'] . ($row['num_replies'] == 0 ? '.0' : '.msg' . $row['id_last_msg']) . ';topicseen#msg' . $row['id_last_msg'],
            'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . ($row['num_replies'] == 0 ? '.0' : '.msg' . $row['id_last_msg']) . ';topicseen#msg' . $row['id_last_msg'] . '">' . $row['lastSubject'] . '</a>'
         ),
         'new' => $row['isRead'],
         'new_from' => $row['new_from'],
         'new_href' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['new_from'] . ';topicseen#new',
         'href' => $scripturl . '?topic=' . $row['id_topic'] . ($row['num_replies'] == 0 ? '.0' : '.msg' . $row['new_from']) . ';topicseen' . ($row['num_replies'] == 0 ? '' : 'new'),
         'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . ($row['num_replies'] == 0 ? '.0' : '.msg' . $row['new_from']) . ';topicseen#msg' . $row['new_from'] . '">' . $row['firstSubject'] . '</a>',
         'is_sticky' => !empty($modSettings['enableStickyTopics']) && !empty($row['isSticky']),
         'is_locked' => !empty($row['locked']),
         'is_poll' => $modSettings['pollMode'] == '1' && $row['id_poll'] > 0,
         'is_hot' => $row['num_replies'] >= $modSettings['hotTopicPosts'],
         'is_very_hot' => $row['num_replies'] >= $modSettings['hotTopicVeryPosts'],
         'is_posted_in' => false,
         'icon' => $row['firstIcon'],
         'icon_url' => $settings[$icon_sources[$row['firstIcon']]] . '/post/' . $row['firstIcon'] . '.gif',
         'subject' => $row['firstSubject'],
         'replies' => $row['num_replies'],
         'views' => $row['num_views'],
         '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>'
         )
      );

      determineTopicClass($topics[$row['id_topic']]);
   }
   $smcFunc['db_free_result']($request);

   if (!empty($modSettings['enableParticipation']) && !empty($topic_ids))
   {
      $result = $smcFunc['db_query']("", "
         SELECT id_topic
         FROM ".$db_prefix."messages
         WHERE id_topic IN (" . implode(', ', $topic_ids) . ")
            AND id_member = {int:id_member}",
         array('id_member' => $user_info['id']));
      while ($row = $smcFunc['db_fetch_assoc']($result))
      {
         if (empty($topics[$row['id_topic']]['is_posted_in']))
         {
            $topics[$row['id_topic']]['is_posted_in'] = true;
            $topics[$row['id_topic']]['class'] = 'my_' . $topics[$row['id_topic']]['class'];
         }
      }
      $smcFunc['db_free_result']($result);
   }

   }

if (!empty($topics))
    {
    echo '
        <div class="tborder" ', $context['browser']['needs_size_fix'] && !$context['browser']['is_ie6'] ? 'style="width: 100%;margin:0px;"' : 'style="margin:0px;"', '>
            <table border="0" width="100%" cellspacing="1" cellpadding="1" class="bordercolor">
                <tr>';


    echo '
                </tr>';

    echo '
            <tr class="titlebg">
               <td width="10%" colspan="2"> </td>
               <td>', $txt['subject'], '
               </td><td width="14%">', $txt['posted_by'], '
               </td><td width="4%" align="center">', $txt['replies'], '
               </td><td width="4%" align="center">', $txt['views'], '
               </td><td width="24%">', $txt['last_post'], '
               </td>
            </tr>';

   foreach ($topics as $topic)
   {
      // Do we want to seperate the sticky and lock status out?
      if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'sticky') !== false)
         $topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_sticky'));
      if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'locked') !== false)
         $topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_locked'));

      echo '
            <tr>
               <td class="windowbg2" valign="middle" align="center" width="6%">
                  <img src="' . $settings['images_url'] . '/topic/' . $topic['class'] . '.gif" alt="" />
               </td><td class="windowbg2" valign="middle" align="center" width="4%">
                  <img src="' . $topic['first_post']['icon_url'] . '" alt="" align="middle" />
               </td><td class="windowbg' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '3' : '' , '" width="48%" valign="middle">' , $topic['is_locked'] && !empty($settings['seperate_sticky_lock']) ? '
                  <img src="' . $settings['images_url'] . '/icons/quick_lock.gif" align="right" alt="" style="margin: 0;" />' : '' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '
                  <img src="' . $settings['images_url'] . '/icons/show_sticky.gif" align="right" alt="" style="margin: 0;" />' : '', $topic['first_post']['link'];
               if ($topic['new'] == 0)
                  {
                  echo '<a href="', $topic['new_href'], '"> <img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt['seconds_with'], '" /></a>';
                  }
                echo '
               <span class="smalltext">', $topic['board']['link'], '</span></td>
               <td class="windowbg2" valign="middle" width="14%">
                  ', $topic['first_post']['member']['link'], '</td>
               <td class="windowbg" valign="middle" width="4%" align="center">
                  ', $topic['replies'], '</td>
               <td class="windowbg" valign="middle" width="4%" align="center">
                  ', $topic['views'], '</td>
               <td class="windowbg2" valign="middle" width="22%">
                  <a href="', $topic['last_post']['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt['last_post'], '" title="', $txt['last_post'], '" style="float: right;" /></a>
                  <span class="smalltext">
                     ', $topic['last_post']['time'], '<br />
                     ', $txt['by'], ' ', $topic['last_post']['member']['link'], '
                  </span>
               </td>
            </tr>';
   }

    echo '</table></div>';

    }
   else
       echo '<b><u>'.$heading.'<br><br>No Topics Match Search Criteria</u></b>';


leftezi

#54
I think you miss nothing.
It works perfect without errors in the log.  O0 O0
Thank you!  :)




A request from many members for more space and easier reading in mobile devices: If it is possible to have Replies/Views together in the same column like in the board index.




And in the future the option to have small avatars in the last post column maybe?

leftezi

A question:

The string for the Topic title is

$txt['subject']

With is the string for the Board title?
I have a friend who have separated the board titles in another column but he don't know the string and the column has no title in the top.

WillyP

Its easy to find any string just open the string file in your editor and do a search for the text displayed.

leftezi

Witch file do you mean? If you mean the courent block code, there was no Boards column in the layout to find the title.

WillyP

Eh... I think I misunderstood your question. Sorry.

leftezi

#59
I could make my own string but I am not sure from witch file the strings reading the source to put it in there. Are they in the modifications.php?

Edit: I found it. The strings are readed from the Modifications.greek-utf8.php file (in my language). I put my own string there and now i have a title in the Boards column.

EDIT again: This way a had errors. I found the original source file for the string. This is in index.greek-utf8.php and the string for the Board title is $txt['board']
So simple!!  :2funny:

This website is proudly hosted on Crocweb Cloud Website Hosting.