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,917
  • Total Topics: 21,308
  • Online today: 884
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 556
  • Total: 556

custom "Recent Topics from Board X, Y, Z only" php block

Started by iowamf, November 04, 2005, 09:47:16 AM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

alhaudhie

its show url of msg not the msg exactly...

like

a href="http://myforum.net/index.php?topic=4341.msg25209# but not the msg in that url.

IchBin

It only shows the link because that is all the code was made to show. If you want the message to show, you'll have to pick some code in this topic that does what you want.

alhaudhie


Loky

Any idea how can I order the list of topics by start date not by the last reply?

Thanks in advance.

EDIT:
I found a solution for it:
http://www.tinyportal.net/index.php?topic=14887.msg207401#msg207401

Cheers.

Ibexy

I am using the following code on my front page to display topics from selected boards (thanks to this thread). Its working 100% The problem is that some topics show which I dont want. Is there a way I can also select which topics show up from these selected boards? Something like entering the topic ID or something? Below is the code:

       
       
global $scripturl;

echo '<div style="overflow: auto; height: 700px">';

echo '
                        <table border="0" width="97%" cellspacing="1" cellpadding="4" class="bordercolor">
                               <tr><td colspan="3" class="titlebg"></td></tr> ';


       $what=ssi_recentTopics('500', array(11,40,43,45,46,54,55,58,60,65,70,71), 'array');


        foreach ($what as $topic)
        {
                echo '
                                <tr>
                                        <td class="windowbg" valign="middle">
                                                ', $topic['link'],' - [', $topic['board']['link'], ']';

                                             

                // Is this topic new? (assuming they are logged in!)
                if (!$topic['new'] && $context['user']['is_logged'])
                        echo '
                                                <a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['new_from'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';

                echo '
                                        </td>
                                        <td class="windowbg2" valign="middle" width="20%">
                                                ', $topic['poster']['link'], '
                                        </td>
                                        <td class="windowbg2" valign="middle" width="35%">';
                if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
                        echo '
                                        <a href="', $topic['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" border="0" style="float: right;" /></a>';
                echo '
                                                <span class="smalltext">
                                                        ', $topic['time'], '
                                                </span>
                                        </td>
                                </tr>';
        }

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

IchBin

You can't randomly select topics to show or not show. That would be a completely different script in which you would have to specify topics instead of calling a function for "recent topics".

Ibexy

ah I see.
Please, is there any code snippet somewhere I can use for this?

IchBin

I don't think I've ever seen a snippet like that made.

villano666

Hi, I'm using this code and I want the new icon and de "by" to be next to the thread link not to be above
How can I do this?

$result=ssi_recentTopics(10,array(11,12),'return');
echo'<right>';
echo '<ul style="padding-left: 15px;">';
foreach($result as $my){
echo '<Li>'.$my['link'].'</Li>';
if(!$my['new'])
echo '<a href="'.$my['href'].'"><img border="0" src="'.$settings['images_url'].'/'.$context['user']['language'].'/new.gif" alt="new" /></a>';
echo ' by ', $my['poster']['link'];
}
echo '</UL>';
echo'</center>';
echo '<span class="smalltext"></span>';


Thanks in advance

alhaudhie

Quote from: smartmouse on January 24, 2007, 12:59:13 PM
Add this code in SSI.php file

Quotefunction ssi_recentTopics_NEW($num_recent = 8, $include_boards = null, $output_method = 'echo')
{
   global $context, $settings, $scripturl, $txt, $db_prefix, $ID_MEMBER;
   global $user_info, $modSettings, $func;

   $include_boards = empty($include_boards) ? array() : $include_boards;

   $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';

   // Find all the posts in distinct topics.  Newer ones will have higher IDs.
   $request = db_query("
      SELECT
         m.posterTime, ms.subject, m.ID_TOPIC, m.ID_MEMBER, m.ID_MSG, b.ID_BOARD, b.name AS bName,
         IFNULL(mem.realName, m.posterName) AS posterName, " . ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' : '
         IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, 0)) >= m.ID_MSG_MODIFIED AS isRead,
         IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from') . ", LEFT(m.body, 384) AS body, m.smileysEnabled, m.icon
      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 = m.ID_MEMBER)" . (!$user_info['is_guest'] ? "
         LEFT JOIN {$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = t.ID_TOPIC AND lt.ID_MEMBER = $ID_MEMBER)
         LEFT JOIN {$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = b.ID_BOARD AND lmr.ID_MEMBER = $ID_MEMBER)" : '') . "
      WHERE t.ID_LAST_MSG = m.ID_MSG
         AND b.ID_BOARD = t.ID_BOARD" . (empty($include_boards) ? '' : "
         AND b.ID_BOARD IN (" . implode(', ', $include_boards) . ")") . "
         AND $user_info[query_see_board]
         AND ms.ID_MSG = t.ID_FIRST_MSG
      ORDER BY t.ID_LAST_MSG DESC
      LIMIT $num_recent", __FILE__, __LINE__);
   $posts = array();
   while ($row = mysql_fetch_assoc($request))
   {
      $row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileysEnabled'], $row['ID_MSG']), array('
' => '')));
      if ($func['strlen']($row['body']) > 128)
         $row['body'] = $func['substr']($row['body'], 0, 128) . '...';

      // Censor the subject.
      censorText($row['subject']);
      censorText($row['body']);

      if (empty($modSettings['messageIconChecks_disable']) && !isset($icon_sources[$row['icon']]))
         $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.gif') ? 'images_url' : 'default_images_url';

      // 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' => shorten_subject($row['subject'], 25),
         'preview' => $row['body'],
         'time' => timeformat($row['posterTime']),
         'timestamp' => forum_time(true, $row['posterTime']),
         'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . ';topicseen#new',
         'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . '#new">' . $row['subject'] . '</a>',
         'new' => !empty($row['isRead']),
         'new_from' => $row['new_from'],
         'icon' => '<img src="' . $settings[$icon_sources[$row['icon']]] . '/post/' . $row['icon'] . '.gif" align="middle" alt="' . $row['icon'] . '" border="0" />',
      );
   }
   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'] . '.msg' . $post['new_from'] . ';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>';
}

Then in administration panel create a new phpbox and paste this code:

Quoteglobal $context, $scripturl;
$bullet = '<img src="'.$settings['images_url'].'/TPdivider.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
$result=ssi_recentTopics_NEW(10,array(9),'return');
foreach($result as $my){
  echo "$bullet";
  echo '<span class="smalltext">'.$my['link'];
  // is this topic new? (assume they are logged in)
if (!$my['new'] && $context['user']['is_logged'])
echo '
                                                <a href="', $scripturl, '?topic=', $my['topic'], '.from', $my['newtime'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';
echo '
';
}
echo '</span>';

"9" is the board ID, change it to select the prefer board to be listed in the module.

I hope this can help, sorry for my english.

why the topic text is smaller after one by topic?

This website is proudly hosted on Crocweb Cloud Website Hosting.